Prev: www.jerseysuppliers.com Wholesale Cheap NFL Jerseys,NHL Jerseys,MLB Jerseys
Next: ezplot problem
From: jatin mistry on 17 Apr 2010 02:37 function stitchSequential()%directory) directory = uigetdir('C:') dir ImageDirectory=dir(directory) files={ImageDirectory.name} files = files(3:end) % ignore . and .. fileName=char(files) size(fileName) fileSize=size(fileName) fileSize(1) fileSize(2) directory %read all the images in the specified directory for f=1:fileSize(1) imageName=[fileName(f,:)] [directory '/' imageName ] Mosaic(:,:,:,f) = double(imread([directory '/' imageName ])); end % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%% % % Only run the following lines ones, and comment out for next runs %%%Here 4 corresponding point of each image set should be picked % HM=1; % for n=1:fileSize(1)-1 % figure(n), % subplot(121); % [xIm1,yIm1] = pick4points(Mosaic(:,:,:,n)/255, 'Mosaik image no 1'); % subplot(122); % [xIm2,yIm2] = pick4points(Mosaic(:,:,:,n+1)/255, 'Mosaik image no 2'); % H=Dlt_H([xIm1 yIm1],[xIm2 yIm2]) % HM=H*HM % save(['HomographyH' num2str(n)],'H') % save(['HomographyHM' num2str(n)],'HM') % end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% %start with the first image as reference image to stich the 2nd on [x1,y1,z1]=size(Mosaic(:,:,:,1)); % boundingBox=zeros(x1,y1,z1); % boundingBox(1:end,1:end,:)=Mosaic(:,:,:,1); refIm=Mosaic(:,:,:,1); figure(1),imshow(refIm/255),pixval on [xIm1,yIm1] = pick4points; HM=1; for n=1:fileSize(1)-1 figure(n), figure(n+1) imshow(Mosaic(:,:,:,n+1)/255) [xIm2,yIm2] = pick4points; H=Dlt_H([xIm1 yIm1],[xIm2 yIm2]) % HM=H*HM % save(['HomographyH' num2str(n)],'H') % save(['HomographyHM' num2str(n)],'HM') % % %load the corresponding homography data for each image pair % HomHFileName=['HomographyH' num2str(n)] % HomHMFileName=['HomographyHM' num2str(n)] % load(HomHFileName) % load(HomHMFileName) % H % HM [xBB1,yBB1,zBB1]=size(refIm) % boundingBox(1:xBB1,1:yBB1,:)=refIm; [maximum_x,minimum_x,maximum_y,minimum_y,dx,dy,MinToMaxX,MinToMaxY]=BBoxNew(refIm, Mosaic(:,:,:,n+1), inv(H)); boundingBox=zeros(MinToMaxY,MinToMaxX,z1); % [xBB1,yBB1,zBB1]=size(boundingBox) boundingBox(dy:xBB1+dy-1,dx:yBB1+dx-1,:)=refIm; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% I'm getting an error : " "??? Subscripted assignment dimension mismatch. Error in ==> stitchSequential at 19 end " can any one help me remove the error.... i've put the BBoxNew.m file below....in case any one needs.......but i think BBoxNew.m has no errors.....the only prblm is the error mentioned above.... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function[maximum_x,minimum_x,maximum_y,minimum_y,dx,dy,MinToMaxX,MinToMaxY]=BBoxNew(refImage,image, H12); [x1,y1,z1]=size(refImage);%x is the heigth y is the width [x2,y2,z2]=size(image); originalCorners=[1 1 1 ; y2 1 1 ; 1 x2 1; y2 x2 1]; display(originalCorners); display(originalCorners'); display(H12); display(H12'); for k=1:4 HCorners(:,k)=H12*originalCorners(k,:)'; HCornersNormalized(:,k)=HCorners(:,k)/HCorners(3,k); end display(HCorners); display(HCornersNormalized); %The first row is the x values, the second row is y values %Dertermmination of maximum and minimum values in the rotaded image, by %taking maximum and minimum values of the corner values, maximum_x=round(max(HCornersNormalized(1,:)));%RIGHT minimum_x=round(min(HCornersNormalized(1,:)));%LEFT maximum_y=round(max(HCornersNormalized(2,:)));%bottom minimum_y=round(min(HCornersNormalized(2,:)));%TOP display(maximum_x); display(minimum_x); display(maximum_y); display(minimum_y); %The distance of coordinates between the two images newMinX=min([minimum_x, 0]); newMaxX=max([maximum_x, y1]); newMinY=min([minimum_y, 0]); newMaxY=max([maximum_y, x1]); %the displacement from the border of the boundingbox dx = max(1-minimum_x, 1) dy = max(1-minimum_y, 1) display(newMinX); display(newMaxX); display(newMinY); display(newMaxY); MinToMaxX=newMaxX-newMinX MinToMaxY=newMaxY-newMinY
From: jatin mistry on 17 Apr 2010 11:44 "jatin mistry" <jatinmistry_13(a)yahoo.co.in> wrote in message <hqbkuh$4eq$1(a)fred.mathworks.com>... > function stitchSequential()%directory) > directory = uigetdir('C:') > dir > ImageDirectory=dir(directory) > files={ImageDirectory.name} > files = files(3:end) % ignore . and .. > fileName=char(files) > size(fileName) > fileSize=size(fileName) > fileSize(1) > fileSize(2) > directory > > %read all the images in the specified directory > for f=1:fileSize(1) > imageName=[fileName(f,:)] > [directory '/' imageName ] > Mosaic(:,:,:,f) = double(imread([directory '/' imageName ])); > end > % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > %%%%%%%%%%%%%%%%%%%%% > % % Only run the following lines ones, and comment out for next runs > %%%Here 4 corresponding point of each image set should be picked > % HM=1; > % for n=1:fileSize(1)-1 > % figure(n), > % subplot(121); > % [xIm1,yIm1] = pick4points(Mosaic(:,:,:,n)/255, 'Mosaik image no 1'); > % subplot(122); > > % [xIm2,yIm2] = pick4points(Mosaic(:,:,:,n+1)/255, 'Mosaik image no 2'); > % H=Dlt_H([xIm1 yIm1],[xIm2 yIm2]) > % HM=H*HM > % save(['HomographyH' num2str(n)],'H') > % save(['HomographyHM' num2str(n)],'HM') > % end > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > %%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > %start with the first image as reference image to stich the 2nd on > [x1,y1,z1]=size(Mosaic(:,:,:,1)); > % boundingBox=zeros(x1,y1,z1); > % boundingBox(1:end,1:end,:)=Mosaic(:,:,:,1); > refIm=Mosaic(:,:,:,1); > figure(1),imshow(refIm/255),pixval on > [xIm1,yIm1] = pick4points; > HM=1; > > for n=1:fileSize(1)-1 > figure(n), > figure(n+1) > imshow(Mosaic(:,:,:,n+1)/255) > [xIm2,yIm2] = pick4points; > H=Dlt_H([xIm1 yIm1],[xIm2 yIm2]) > % HM=H*HM > % save(['HomographyH' num2str(n)],'H') > % save(['HomographyHM' num2str(n)],'HM') > % > % %load the corresponding homography data for each image pair > % HomHFileName=['HomographyH' num2str(n)] > % HomHMFileName=['HomographyHM' num2str(n)] > % load(HomHFileName) > % load(HomHMFileName) > % H > % HM > [xBB1,yBB1,zBB1]=size(refIm) > % boundingBox(1:xBB1,1:yBB1,:)=refIm; > [maximum_x,minimum_x,maximum_y,minimum_y,dx,dy,MinToMaxX,MinToMaxY]=BBoxNew(refIm, Mosaic(:,:,:,n+1), inv(H)); > boundingBox=zeros(MinToMaxY,MinToMaxX,z1); > % [xBB1,yBB1,zBB1]=size(boundingBox) > boundingBox(dy:xBB1+dy-1,dx:yBB1+dx-1,:)=refIm; > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > > I'm getting an error : > " > "??? Subscripted assignment dimension mismatch. > > Error in ==> stitchSequential at 19 > end " > > can any one help me remove the error.... > i've put the BBoxNew.m file below....in case any one needs.......but i think BBoxNew.m > has no errors.....the only prblm is the error mentioned above.... > > > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > function[maximum_x,minimum_x,maximum_y,minimum_y,dx,dy,MinToMaxX,MinToMaxY]=BBoxNew(refImage,image, H12); > [x1,y1,z1]=size(refImage);%x is the heigth y is the width > [x2,y2,z2]=size(image); > originalCorners=[1 1 1 ; y2 1 1 ; 1 x2 1; y2 x2 1]; > display(originalCorners); > display(originalCorners'); > display(H12); > display(H12'); > > for k=1:4 > HCorners(:,k)=H12*originalCorners(k,:)'; > HCornersNormalized(:,k)=HCorners(:,k)/HCorners(3,k); > end > > display(HCorners); > display(HCornersNormalized); > %The first row is the x values, the second row is y values > %Dertermmination of maximum and minimum values in the rotaded image, by > %taking maximum and minimum values of the corner values, > maximum_x=round(max(HCornersNormalized(1,:)));%RIGHT > minimum_x=round(min(HCornersNormalized(1,:)));%LEFT > maximum_y=round(max(HCornersNormalized(2,:)));%bottom > minimum_y=round(min(HCornersNormalized(2,:)));%TOP > display(maximum_x); > display(minimum_x); > display(maximum_y); > display(minimum_y); > %The distance of coordinates between the two images > newMinX=min([minimum_x, 0]); > newMaxX=max([maximum_x, y1]); > newMinY=min([minimum_y, 0]); > newMaxY=max([maximum_y, x1]); > %the displacement from the border of the boundingbox > dx = max(1-minimum_x, 1) > dy = max(1-minimum_y, 1) > > display(newMinX); > display(newMaxX); > display(newMinY); > display(newMaxY); > MinToMaxX=newMaxX-newMinX > MinToMaxY=newMaxY-newMinY plz ne 1 can debug the above error.... i'm new to matlab.... plz help....
From: Walter Roberson on 17 Apr 2010 12:09 jatin mistry wrote: > "jatin mistry" <jatinmistry_13(a)yahoo.co.in> wrote in message >> for f=1:fileSize(1) >> imageName=[fileName(f,:)] >> [directory '/' imageName ] >> Mosaic(:,:,:,f) = double(imread([directory '/' imageName ])); >> end >> I'm getting an error : >> " >> "??? Subscripted assignment dimension mismatch. >> >> Error in ==> stitchSequential at 19 >> end " >> >> can any one help me remove the error.... Your code assumes that every image is exactly the same size. If that is not the case, then you would get exactly the error you mention. If you were to store the imread result into a temporary variable, you would then be able to use size() to determine its dimensions, and you could then use those dimensions explicitly in the following assignment: thisimage = double(imread([directory '/' imageName ])); [xs, ys, zs] = size(thisimage); Mosaic(1:xs, 1:ys, 1:zs, f) = thisimage; This will have the effect of automatically expanding any previous images (with 0's) if a larger image comes along.
From: jatin mistry on 17 Apr 2010 13:19 Walter Roberson <roberson(a)hushmail.com> wrote in message <hqcmf9$ko$1(a)canopus.cc.umanitoba.ca>... > jatin mistry wrote: > > "jatin mistry" <jatinmistry_13(a)yahoo.co.in> wrote in message > > >> for f=1:fileSize(1) > >> imageName=[fileName(f,:)] > >> [directory '/' imageName ] > >> Mosaic(:,:,:,f) = double(imread([directory '/' imageName ])); > >> end > > >> I'm getting an error : > >> " > >> "??? Subscripted assignment dimension mismatch. > >> > >> Error in ==> stitchSequential at 19 > >> end " > >> > >> can any one help me remove the error.... > > Your code assumes that every image is exactly the same size. If that is > not the case, then you would get exactly the error you mention. > > If you were to store the imread result into a temporary variable, you > would then be able to use size() to determine its dimensions, and you > could then use those dimensions explicitly in the following assignment: > > thisimage = double(imread([directory '/' imageName ])); > [xs, ys, zs] = size(thisimage); > Mosaic(1:xs, 1:ys, 1:zs, f) = thisimage; > > This will have the effect of automatically expanding any previous images > (with 0's) if a larger image comes along. i tried what u have suggested but it still gives the same error... ??? Subscripted assignment dimension mismatch. Error in ==> stitchSequential at 19 thisimage = double(imread([directory '/' imageName ])); plz do suggest something else.... thanks for ur reply and help. :) ....but ...it still doesnt solve the prblm....
From: jatin mistry on 17 Apr 2010 14:03 @ Walter Roberson Hello Sir, thank you for your valuable response but it doesn't seem to solve my problem plz help...
|
Next
|
Last
Pages: 1 2 Prev: www.jerseysuppliers.com Wholesale Cheap NFL Jerseys,NHL Jerseys,MLB Jerseys Next: ezplot problem |