Conversion pixel size into mm ?

16 views (last 30 days)
Lequette Kevin
Lequette Kevin on 6 May 2019
Commented: Image Analyst on 24 Jul 2020
Hello,
I'm a beginner with matlab. I have a 3D matrix. I binarize my image with a specific threshold. And I counted the pixel==1 along this matrix to visualize to accumulation of matter inside a labyrinth. For moment, I just have the relative thinkness by counting the pixel ==1/total pixel. However, I would like to know the thinkness of this accumulation. I know that I have to convert my pixel in a mm scale but I don't know how :/ Any help please ?
This is my code for the following image:
figure, contourf(squeeze(mean(Bimg,1,'omitnan')))
a=colorbar;
set(gca,'clim',[0 0.4]);
set(gcf,'color','w');
a.Label.String = 'relative thinkness (%)';
axis off;
  5 Comments
Lequette Kevin
Lequette Kevin on 7 May 2019
Edited: Lequette Kevin on 7 May 2019
I think that i am not clear enough, sorry. I have a 3D object (x, y, z), with an accumulation of matter inside. I would like measure the thinckness of this accumulation (on z axis) and make a 2D visualization of this accumulation. However, I do not manage to apply the real units to my pixels.
I know the width, the height and the depth of each pixel (thank to imageJ). However, I would like apply these data to my 3D matrix binarized on MatLab.
width= 0.016 mm
height= 0.0029 mm
Voxel depth = 0.019 mm
Walter Roberson
Walter Roberson on 7 May 2019
sum() the matrix along the third dimension and multiply by the thickness of one pixel ?

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 6 May 2019
See my attached spatial calibration demo.
  6 Comments
agung pratama
agung pratama on 23 Jul 2020
Edited: agung pratama on 23 Jul 2020
I have same problem, idon't understand what is the relation between the colorbar value with mm or other units in real.
Image Analyst
Image Analyst on 24 Jul 2020
The colorbar maps your grayscale image into a colorized, RGB image via a colormap. The colormap is an N-by-3 matrix of RGB values in the range 0-1 with the first column being the red value, the second value being the green value, and the third value being the blue value. So if you use a colormap, you can consider your gray scale image as now being an "indexed" image since every gray scale in your image will correspond to a certain row (index) in the color map that says what color to display that gray scale as. Does that make sense?
In addition, you can specify what gray level corresponds to the first color (row 1 of the colormap, or the bottom row of the colorbar) and what gray level corresponds to the last color (top color in the colorbar). You do this with the caxis() function. If you don't use caxis(), your min value of your image will be the bottom color and the max value of your image will be the top color, with the in between values linearly corresponding to the in between colors. If you do use caxis(), and values below the lowest value you specify will show up as that bottom color, and any values in your image above the high value you used in caxis() will be the top color.
For example if your image ranges from -20 to +300, and you use 256 colors in the "jet" map:
imshow(grayImage, []); % Display the image
cmap = jet(256) % Blue at bottom, red at top.
colormap(cmap); % Apply colormap
colorbar; % Show color bar beside the image.
Then if you use
caxis([0, 255]); % Blue for 0 and below, and red for 255 and above.
then any values from -20 to 0 will show up as blue and any values from 255 to 300 will show up as red.
So that's how the colormap and colorbar relate to the intensity image. Now you asked "what is the relation between the colorbar value with mm or other units in real". The colormap applies to the intensity, not the distance in the plane of the image. So for the colormap to apply to real units of mm, your intensity of your image would have to correspond to units of mm. For example, the image could be a profilometer image of your hand. So essentially your image is a topographic image where intensity corresponds to height. So maybe you'd have a profilometer image where the heights range from -5 to +30 mm, and your gray levels are also in that range. Then if you want 0 to show up as blue, and 25 mm to show up as red, you'd use those values in caxis():
caxis([0, 25]);

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!