Averaging in a loop to stop uint16 from saturating

2 ビュー (過去 30 日間)
Robert Roy
Robert Roy 2016 年 5 月 8 日
コメント済み: Image Analyst 2016 年 5 月 8 日
Hi guys, I am doing some image processing, and what happens is I record a number of images,store them in a set and do some processing and then average for a number of sets recorded.However I have a problem where because the images are uint16 it saturates before imaging, I am just wondering if there is a way to average as I go along or any other way round this. Ive tried to change the type to a larger uint but that doesnt seem to work.
if true
for n=1:10
stem='E:\29th April New\NEW Gain=99_No Delay_ Gate=0.02_0';
r=n-1;
r=int2str(r);
combinedStr=strcat(stem,r);
Images=99;
t=10;
AvgImg = uint16(zeros(1024,1280));
for i=t:Images
B=readimx(fullfile(combinedStr,['B000',int2str(i),'.im7']));
C=B.Frames{1}.Components{1};
V = C.Planes;
Img = V{1,1};
J = imrotate(Img,-90);
I2 =(flip(J,2));
FUNC=@(x)max(x(:));
I3=medfilt2(I2,[1 1]);
AvgImg = AvgImg +I3;
end
AverageImg = AvgImg/(Images-t);
AverageImgB=90;
AverageImgLII=(AverageImg-AverageImgB);
K=imagesc(flipud(AverageImgLII));
end

採用された回答

Image Analyst
Image Analyst 2016 年 5 月 8 日
It needs to be double to avoid clipping
AvgImg = zeros(1024,1280); % Before the loop
AvgImg = AvgImg + double(I3); % In the loop
  2 件のコメント
Robert Roy
Robert Roy 2016 年 5 月 8 日
That seems like it helps but now my colorscale seems to be off especially with the background of the image.
Image Analyst
Image Analyst 2016 年 5 月 8 日
You can send in different values to caxis(). Or you can use [] if it's a gray scale image
imshow(AvgImg, []);
colormap(gray(256));
colorbar;

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by