imadjust doesn't return the same image

1 次查看(过去 30 天)
Sum = imadjust(Sum,[],[],1.);
This should return Sum with no changes, right? The figure is almost all white.
imshow(uint8(Sum))
figure(4)
Sum = imadjust(Sum,[],[],1.);
imshow(Sum)

回答(2 个)

Walter Roberson
Walter Roberson 2016-10-30
If you had read in a uint8 image, and had used double() with it, then your Sum array would be class double with values in the range 0 to 255. imshow(uint8(Sum)) would "undo" the double() , diplaying the image in its uint8 form. But the imadjust() on the double() version of it would leave the data completely unchanged including still being double(). And you did not use uint8() on your second imshow(), so it would be trying to imshow data that is way out of range for images of class double.
For example,
Sum = double(imread('cameraman.tif'));
subplot(1,2,1)
imshow(uint8(Sum));
subplot(1,2,2)
imshow(Sum)
  1 个评论
Douglas Brenner
Douglas Brenner 2016-10-30
Sorry but I don't understand. Why would imadjust on a double return the same answer? Running it Sum = imadjust(Sum,[],[],1.); converts the range to 0 - 1 from 0 -82 whether I run it as above or Sum = imadjust(double(Sum),[],[],1.);

请先登录,再进行评论。


Image Analyst
Image Analyst 2016-10-30
Use [] to fix it. Sum is a double image and any values over 1 will display as white unless you use [] to scale min to max to the range 0-255.
imshow(Sum, []);
  1 个评论
Douglas Brenner
Douglas Brenner 2016-10-31
Let me know what to do if this post isn't readable. I added the [] in imshow but it only makes figure 3 a little easier to see. fig 4 and 6 are white, 5 is grey. 4 and 6 do show the scale that is in 3. Shall I send a image? close all
include i = 3; %for i = 5:5%1:nimages; % aviin = [transformeddir,base_name,'_transformed_', int2str(i),'.avi']; aviin = [aligneddir,base_name,'_aligned_', int2str(i),'.avi']; disp('Converting') disp(aviin) a = VideoReader(aviin) n_frames = a.NumberOfFrames; frame=read(a,1); figure (1) [frame,thres] = edge(frame,'sobel'); thres figure(2) imshow(frame); Sum=double(frame); for j = 2:n_frames; frame = double(read(a,j)); frame = edge(frame,'sobel',thres); Sum = Sum + frame; end % Mean = Sum / n_frames; figure(3); max( max(Sum)) min( min(Sum)) imshow(uint8(Sum),[]) % Sum = 255*uint8(Sum/max(Sum)); % Sum = histeq(Sum,8); figure(4) Sum = imadjust(Sum,[],[],1.); max( max(Sum)) min( min(Sum)) %Sum = imadjust(Sum,[0;82/255],[0; 1],1.); imshow(uint8(Sum),[]); figure(5); Sum = 255*Sum; figure(6) imshow(uint8(Sum),[]);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by