matlab - Extracting a window from an image in each frame -


i need extract window of size, let's may m*n, image window size varies each image of frame. bigger or smaller, , problem have add last frame current , same size of matrix can add together.

this have tried. did take took 4 possibilities account, results i'm not getting not satisfactory.

do have suggestions?

[f1, f2]=size(hscf); [f11, f22]=size(hstcf);              if( f1> f11  && f2>f22)     c=zeros(f1,f2);     i=1:1:f11         j=1:1:f22             c(i,j)=hstcf(i,j);              end              end     hstcf=c;               elseif(f1<f11 &&f2<f22)     c=zeros(f1,f2);     i=1:1:f1         j=1:1:f2             c(i,j)=hstcf(i,j);         end end     hstcf=c; elseif(f1>f11 && f2<f22)     c=zeros(f1,f2);     i=1:1:f11         j=1:1:f2             c(i,j)=hstcf(i,j)  end     end     hstcf=c; elseif(f1<f11 && f2>f22)     c=zeros(f1,f2);     i=1:1: f1         j=1:1:f22             c(i,j)=hstcf(i,j);         end     end     hstcf=c;     elseif(f1<f11 && f2==f22)     c=zeros(f1,f2);     i=1:1: f1         j=1:1:f22             c(i,j)=hstcf(i,j);         end     end     hstcf=c;     elseif(f1>f11 && f2==f22)     c=zeros(f1,f2);     i=1:1: f11         j=1:1:f22             c(i,j)=hstcf(i,j);         end     end     hstcf=c;     elseif(f1==f11 && f2>f22)     c=zeros(f1,f2);     i=1:1: f1         j=1:1:f22             c(i,j)=hstcf(i,j);         end     end     hstcf=c;     elseif(f1==f11 && f2<f22)     c=zeros(f1,f2);     i=1:1: f1         j=1:1:f2             c(i,j)=hstcf(i,j);         end     end     hstcf=c;  end  

as understand trying copy small image large image, starting @ top left corner of large image. if so, error due following reason. correctly copy small image first empty matrix called c. after iteration, have directly copied modified c original large image (hstcf=c). please check following code snippet.

hscf = imread('cameraman.tif'); subplot(1,3,1); imshow(hscf);  title(strcat(num2str(size(hscf,1)), 'x', num2str(size(hscf,2)))); hstcf = imresize(imread('coins.png'), .5); subplot(1,3,2); imshow(hstcf); title(strcat(num2str(size(hstcf,1)), 'x', num2str(size(hstcf,2))));  [f1, f2]=size(hscf); [f11, f22]=size(hstcf);  if (f1>f11 && f2>f22)     i=1:f11         j=1:f22             hscf(i,j)=hstcf(i,j);         end     end end  subplot(1,3,3); imshow(hscf); title(strcat(num2str(size(hscf,1)), 'x', num2str(size(hscf,2)))); 

output of code looks follows,

enter image description here


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -