Question about Imaging functions

조회 수: 2 (최근 30일)
Happy PhD
Happy PhD 2018년 5월 25일
답변: Guillaume 2018년 5월 25일
Hi,
I have done some measurement of a light source that I like to display in MATLAB. I want to look at the intensities for each pixel. But I don't understand some of the imaging functions. For example, my image is a 12 bit image.
imshow(my_image) shows the image with no visible coordinate system. Its black and white (the image is in gray scale). It looks very rough. Pixel info shows the coordinate system and the intensity is a value like 3.0E+30 . The label from figure shows [X,Y]:[1200 59], Index 304; [R,G,B]:[1 1 1].
image(my_image) shows just a blue image (I don't see the object ???). Index here is 0,2 to 0,006 something of magnitude.
image(my_image/max(my_image(:))*100) shows a blue, yellow and red image. I see my object. The red and yellow is where I have my object with certain intensity. Max intensity is something like 90, this label shows Index 90.19. I think "my_image/max(my_image(:))*100" is some kind of normalization.
  1. The question is what is the differencte between these three options?
  2. Which one is more valid to use in image processing?
The pixel intensitis is calibrated with measured total energy.
For example, I want to display the object in coordinate system showing the size in mrad (the angle). I am using the function imref2d, but when I plot this with imshow all the sudden the index is about 1.7 as max. I am also not sure the angle size is correct, but lets assume it is. I don't understand the "new" pixel value. It wouldn't allow me to plot this with image function.
xWorldLimits = [0 size(bild,2)*alphaPixel];
yWorldLimits = [0 size(bild,1)*alphaPixel];
image_mrad = imref2d(size(my_image),xWorldLimits,yWorldLimits);
hIM5 = imshow(my_image,image_mrad);
What am I doing wrong?
Thankful for any insights!
  댓글 수: 7
Happy PhD
Happy PhD 2018년 5월 25일
I see Index with up to 4.0E4 with 'cdata' in imshow. I usually imshow the uploaded_image. But then I create the my_image = my_image/max(my_image(:)*100).
I do some calculations of the intensity within different angles (circles). I am basically calibrating the image so one pixel intensity corresponds to a certain energy. I guess an normalized image like my_image/max(my_image(:)*100) would be fine with this.
sum_pixel = sum(sum(uploaded_image)) % whole image
calib_factor = energy/sum_pixel
uploaded_image = uploaded_image*calib_factor;
Im displaying uplaoded_image.
Happy PhD
Happy PhD 2018년 5월 25일
Hmm, why doesnt the following codes have the same index values?
%%PLOT data
figure(4)
my_image = uploaded_image/max(uploaded_image(:))*100;
hIM4 = image(my_image);
hold on
daspect([1 1 1]);
impixelinfo;
figure(5)
xWorldLimits = [0 size(my_image,2)*alphaPixel];
yWorldLimits = [0 size(my_image,1)*alphaPixel];
image_mrad = imref2d(size(my_image),xWorldLimits,yWorldLimits);
hIM5 = imshow(my_image,image_mrad);
hold on;
impixelinfo;
daspect([1 1 1]);
xlabel('alpha (mrad)')
ylabel('alpha (mrad)')
It should be the same. The last figure just change the coordinate to angle in imref2d.

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2018년 5월 25일
why doesnt the following codes have the same index values
Because image and imshow don't behave the same way at all.
You should not be using image. It maps intensity to a colour map (which by default is parula) and the number of colours in that colour map will affect which intensity value maps to white.
The intensity that imshow maps to white depends on the class of the image. Your cdata image, as loaded is going to be uint16. imshow will associate intensity 65535 (maximum uint16 value to white). However, your image being original 12 bits, its maximum intensity will be 4095. You can tell imshow to use that range instead with:
imshow(cdata, [0 4095]);
Later on, you convert the image to double. For images of class double, matlab assumes the intensity range is [0 1]. Anything above 1 is considered the same as 1. Therefore your conversion would be better implemented as
uploaded_image = (double(cdata)-double(background)) / 4095; %to rescale to range 0-1
Instead what you did is rescale to the range 0-100. As said, for double images, imshow assumes that 1 and anything above is white. You can override that, again by specifying a custom display range:
my_image = uploaded_image/max(uploaded_image(:))*100;
imshow(my_image, [0 100]);
In all cases, impixelinfo should display the true intensity regardless of the display range.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by