What should I put in Filen to place to Function?
Show older comments
function [ tag, out, out2, out3, lMin, lMax, res] = loadBImage(filen)
% Load image from Cono-Point Acquisition
tic
fname = [filen '.dist']
%load float-distances from dist file
fid=fopen(fname)
vals=fread(fid,'float');
fclose(fid);
size(vals)
%load parameters from header file
filename = [filen '.hdr']
fid=fopen(filename);
C=textscan(fid,'%s%s%s')
fclose(fid);
off=str2double(strrep(C{2}(11),',','.')); %get offset
dir=char(C{2}(12)) %get scansion direction
lMin=str2double(C{2}(18)) %get Min-Max WorkingRange
lMax=str2double(C{2}(19))
res=str2double(strrep(C{2}(8),',','.')) %get res
y=str2double(strrep(C{2}(9),',','.')); y=((y-2*off)/res)+1; strrep(y,',','.') %get Xres
x=str2double(strrep(C{2}(10),',','.')); x=x/res+1; strrep(y,',','.') %get Yres
%load SNR file and get %
fid=fopen([filen '.snr']);
snr=fread(fid,'uint16');
fclose(fid);
totalSNR=(sum(snr)/length(snr))/10;
%load TAG file
%fid=fopen([filen '.tag']);
%tag=fread(fid,'uint8');
%fclose(fid);
tag=0
inizio=1;
out=[];
out2=[];
out3=[];
%load image acquired from Y-axis
if dir=='Y'
step=y;
for i=1:x+1
if mod(i,2)==0
col=flipud(vals(inizio:step));
colsnr=flipud(snr(inizio:step));
else
col=vals(inizio:step);
colsnr=snr(inizio:step);
end
inizio=step+1;
step=step+y;
out=cat(2,out,col);
out3=cat(2,out3,colsnr);
end
else if dir == 'X'
%load image acquired from X-axis
step=y-1;
for i=1:(x)
if mod(i,2)==0
row=fliplr(vals(inizio:step)');
row3=fliplr(snr(inizio:step)');
% row2=(tag(inizio:step)');
else
row=vals(inizio:step)';
% row2=tag(inizio:step)';
row3=snr(inizio:step)';
end
inizio=step+1;
step=step+y-1;
%qui sostituire se necessario
%step=step+y-1;
out=cat(1,out,row);
out2=0;%cat(1,out2,row2);
out3=cat(1,out3,row3);
end
end
end
%filter values outside the lens working-range
%out(out<lMin | out>lMax)=NaN;
size(out)
%save M-file
%save([filen '.mat'],'out','out3', 'lMin', 'lMax', 'res');
fid = fopen([filen '.mpd'],'wb')
fwrite(fid,out);
fclose(fid)
fid = fopen([filen '.mps'],'wb')
fwrite(fid,out3);
fclose(fid)
toc
end
I have 4 file .tag , .snr . hdr .dist ....
Answers (1)
The input filen should be the filename without any file extension.
All of the four files must have the same name (only the file extensions are different).
1 Comment
Guillaume
on 8 Jun 2016
@Berto Rossi, please use comment on this answer rather than starting a new answer
Berto Rossi's comment moved here from answer:
But when i try to put the file name in the file, , this is the error
function [ tag, out, out2, out3, lMin, lMax, res] = loadBImage(Argento_3_R)
↑
Error: Function definitions are not permitted in this context.
Categories
Find more on Image Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!