Filter löschen
Filter löschen

Converting idl to matlab and error in code

2 Ansichten (letzte 30 Tage)
hasan alhussaini
hasan alhussaini am 6 Aug. 2017
Beantwortet: Walter Roberson am 6 Aug. 2017
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Aug. 2017
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} );

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by