Error using readmraw Too many output arguments.
11 次查看(过去 30 天)
显示 更早的评论
Hi, I have a problem on the Error using readmraw.Too many output arguments.The problem is that I can use my routine to do post-processing for the images before, but suddenly the error happened. I don't know how to solve. The readmraw function is : function [ImageData] = readmraw(filename,numimgs) % readmraw.m % READMRAW Read 16 bit monchrome Photron image data into a structure % % I=READMRAW('c:\Photron\Filename',[a,b]) loads images a through b from % 'c:\Photron\Filename' into structure I. % % Remarks % ------- % This function must be handed the common *.cih and *.mraw file name % and the range of images to be loaded (Matlab can not handle the entire % image range for large files). A file extension is not allowed. % This function is intended for monochrome 16 bit *.mraw files only. % NOTE: Both the *.cih file and the *.mraw file are utilized % Autor: SEP Creation Date: June 20,2013 % % Examples % -------- % % Load all images % I=readmraw('c:\Photron\Moviefile',[0]); % % Load images 10 through 50 % I=readmraw('c:\Photron\Moviefile',[10,50]); % % Load image 10 % I=readmraw('c:\Photron\Moviefile',[10]); fid1=fopen(sprintf('%s.cih',filename),'r'); fid2=fopen(sprintf('%s.mraw',filename),'r'); if fid1<1 fid2<1 display([filename ' filenames could not be found']); ImageData=0; return; end
% Read Header Information Header=textscan(fid1,'%s','delimiter',':'); Total_Frames=str2double(cell2mat(Header{1}(32))); if isnan(Total_Frames)==1; Total_Frames=str2double(cell2mat(Header{1}(31))); Width=str2double(cell2mat(Header{1}(39))); Height=str2double(cell2mat(Header{1}(41))); CameraSetup.FrameRate=str2double(cell2mat(Header{1}(23))); %Other data from header if desired else %User Defined Camera Name defined, shift 1 bit Width=str2double(cell2mat(Header{1}(40))); Height=str2double(cell2mat(Header{1}(42))); CameraSetup.FrameRate=str2double(cell2mat(Header{1}(24))); %Other data from header if desired end Pixels=Width*Height; fclose(fid1);
% Define Image Range if numimgs==0 % load all the images first_frame=1; frames=Total_Frames; elseif (length(numimgs)==1) % load a single image first_frame=numimgs; frames=1; else % load a specified range of images first_frame=numimgs(1,1); last_frame=numimgs(1,2); frames=last_frame-first_frame+1; end
%Load Images fseek(fid2,(first_frame-1)*Pixels*2,'bof'); I=zeros(Pixels,frames,'uint16'); for n=1:1:frames I(:,n)=(fread(fid2,Pixels,'uint16')); end fclose(fid2); N = [Width Height frames]; ImageData.Images.RawImages=permute(reshape(I,N),[2 1 3]); ImageData.CameraSetup=CameraSetup;
and the post-processing routine is: %function OHchemiluminescence close all clear all
addpath 'D:\Processing\Photron_MRAW_read_function'
threshold = 0.125 xinj = 683; yinj = 234; pxmm = 6.6;
%LoLrange = [7 37]; %FLrange = [13 43];
reps = 10 %%% CHECK REPETITIONS FOR EACH CASE!!!!!
for r=1:reps
name = strcat('test_rep',sprintf('%02d',r)) %%%DONT FORGET TO REMOVER THE +4 BEFORE PROCESSING!
[Images Camera] = readmraw(name,[0]);
%[0 10]; % [a z] for range, [d] for single imagle, [0] for all images
dt = 1/Camera.FrameRate;
ti = .99995;
ti = 0;
tf = ti + dt*(Camera.Frames-1);
time = ti:dt:tf;
img = double(Images.RawImages(:,:,Camera.Frames/2));
mini = min(double(Images.RawImages(:)));
maxi = max(double(Images.RawImages(:)));
%mask = ones(Camera.Height,Camera.Width).*(img>(mini+(threshold*(maxi-mini))));
acum = ones(Camera.Height,Camera.Width);
RES(r).rep = r;
RES(r).time = time;
for n = 1:Camera.Frames
img = Images.RawImages(:,:,n);
mask = ones(Camera.Height,Camera.Width).*(img>(mini+(threshold*(maxi-mini))));
int = sum(mask.*double(img),1);
acum = acum + double(img);
B= bwboundaries(mask,'noholes');
[max_size, max_index] = max(cellfun('size', B, 1));
values = find(int);
if r == 1
figure(1)
subplot(2,2,1)
imshow(img,[mini maxi])
subplot(2,2,2)
imshow(mask)
subplot(2,2,3)
imshow(img,[mini maxi])
hold on
if ~isempty(B)
plot(B{max_index}(:,2),B{max_index}(:,1),'w')
end
colormap(jet)
subplot(2,2,4)
plot(int)
end
if ~isempty(B)
LoL(n) = (xinj - max(B{max_index}(:,2)))/pxmm;
FL(n) = (xinj - min(B{max_index}(:,2)))/pxmm;
else
LoL(n) = NaN;
FL(n) = NaN;
end
end
figure(2)
axis([0 0.01 0 100])
plot(time, LoL,'x')
hold on
plot(time, FL,'x')
if r == 1
display('Select range for LoL average (bottom)')
LoLrange =[ginput(2)];
LoLrange =[find(time>=LoLrange(1),1,'First') find(time<=LoLrange(2),1,'Last')];
display('Select range for FL average (top)')
FLrange =[ginput(2)];
FLrange =[find(time>=FLrange(1),1,'First') find(time<=FLrange(2),1,'Last')];
end
LoLv = LoL(LoLrange(1):LoLrange(2));
[LoLb LoLs] = robustfit(ones(length(LoLv),1),LoLv);
FLv = FL(FLrange(1):FLrange(2));
[FLb FLs] = robustfit(ones(length(FLv),1),FLv);
RES(r).LoL = LoL;
RES(r).FL = FL;
RES(r).LoLavg = LoLb(1);
RES(r).LoLstd = LoLs.s;
RES(r).FLavg = FLb(1);
RES(r).FLstd = FLs.s;
LoLtot(r,:) = LoL;
FLtot(r,:) = FL;
clear LoL FL LoLv LoLb LoLs FLv FLb FLs
end
RES(reps+1).rep = reps+1;
RES(reps+1).time = time; RES(reps+1).LoL = mean(LoLtot); RES(reps+1).FL = mean(FLtot);
plot(time, mean(LoLtot)) plot(time, mean(FLtot)) hold off
[LoLavg LoLstd] = robustfit(ones(1,reps),[RES.LoLavg]); [FLavg FLstd] = robustfit(ones(1,reps),[RES.FLavg]);
RES(reps+1).LoLavg = LoLavg(1); RES(reps+1).LoLstd = LoLstd.s; RES(reps+1).FLavg = FLavg(1); RES(reps+1).FLstd = FLstd.s;
save RES savefig Figure(2)
toc
Thank you all.
0 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!