필터 지우기
필터 지우기

imadjust doesn't return the same image

조회 수: 1 (최근 30일)
Douglas Brenner
Douglas Brenner 2016년 10월 30일
댓글: Douglas Brenner 2016년 10월 31일
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