Problem with the im2uint16

3 ビュー (過去 30 日間)
Efstathios Kontolatis
Efstathios Kontolatis 2016 年 10 月 13 日
I need to create a series of mean images. So I created the following code
function [meanbgimage] = impostprocbg(bgpath)
%Calculates the mean backgroung image
cd(bgpath)
bglist=dir('*.tif');
I0 = imread(bglist(1).name);
sumbgImage = im2double(I0); % Inialize to first image.
k=1;
for i=2:length(bglist) % Read in remaining images
nameused = bglist(i).name;
img = imread(nameused);
% Image = imcomplement(Image);
img=im2double(img);
% img=wiener2(img);
sumbgImage = im2double(imadd(sumbgImage,img));
clear img
if mod(i,100)==0
meanbgimage(:,:,k) = imdivide(sumbgImage,100);
j = meanbgimage(:,:,k);
j = im2uint16(j);
meanbgimage(:,:,k) = j;
sumbgImage = zeros(512,512);
k=k+1;
end
i
end;
The problem is that I need meanbgimage to be an array of uint16 2D arrays. However, this code returns meanbgimage as a double. Does anybody knows what should I do?

採用された回答

KSSV
KSSV 2016 年 10 月 13 日
You can convert double to uint16 using
intmatrix = uint16(matrix)
doc unit16
  1 件のコメント
Efstathios Kontolatis
Efstathios Kontolatis 2016 年 10 月 13 日
Thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by