필터 지우기
필터 지우기

Converting idl to matlab and error in code

조회 수: 2 (최근 30일)
hasan alhussaini
hasan alhussaini 2017년 8월 6일
답변: Walter Roberson 2017년 8월 6일
Hi, I'm trying to convert IDL codes to matlab, the idea is i have dark images and flat images and i'm trying to select them both for another section of the code
I'm stuck on the idl function known as FLOAT
IDL codes
flatlist = file_search(workdir,'flat*')
nflat = n_elements(flatlist)
darklist = file_search(workdir,'dark*')
ndark = n_elements(darklist)
dark = fltarr(xsize,ysize)
flat = fltarr(xsize,ysize)
for k = 0,ndark-1 do begin
imtemp = read_tiff(darklist(k))
dark = dark+float(imtemp)/ndark
;Average dark images
endfor
Matlab version
[darklist,workdir] = uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files'},'Select the dark image(s)','MultiSelect', 'on');
if(~iscell(darklist))
ndark=1;
else
ndark = numel(darklist);
end
dark = zeros(ysize,xsize);
flat = zeros(ysize,xsize);
for k = 1:ndark
if(~iscell(darklist))
imtemp = imread(darklist);
else
imtemp = imread(darklist{k});
dark = dark+double(imtemp)./ndark;
end
end
I'm not sure if its double, also i'm getting this error
Error in
imtemp = imread(darklist{k});
help pls
Thanks

채택된 답변

Walter Roberson
Walter Roberson 2017년 8월 6일
IDL's float(x) call corresponds to real(single(x)) in MATLAB. In the case where the data is known to be real-valued already (which is the case for all images except for some advanced TIFF files, and possibly some dicom files), then that would simplify to just single(x)
"also i'm getting this error"
You would not be having that error if you had used the code I gave you in https://www.mathworks.com/matlabcentral/answers/351336-error-trying-to-read-files#answer_276554
The problem is that your files are in some directory other than your current directory. I showed you earlier,
flatlist = fullfile( workdir, {flatinfo.name} );
and
darklist = fullfile( workdir, {darkinfo.name} );

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by