From: Rebecca Phillips on 17 Oct 2009 21:34 Hi, I'm looking to do some basic image manipulation. I am a beginner with the image processing toolbox, so I thought I'd ask first before I go and do what I need to do by some crazy long-way route. Say I have some image. I want to take a subsection of this image, move this subection withing the parent image, and once I've moved it, make everything except for the subsection I just moved black. For example... I have an RGB image A of size 640x480 (width x height). I want to take the subsection bound by the coordinates (600,0) (640,0) (600,480) (640,480) (the rightmost vertical "strip" of width 40). This subsection has size 40x480. I want to move this subsection all the way to the left edge of the original image A, ie so that the origin of the subsection now lies at (0,0). Now I want to make everything else black, i.e. fill the rectangle bound by (40,0) (640,0) (40,480) (640,480) with black. Any input is greatly appreciated! Kind Regards, Rebecca
From: Rebecca Phillips on 17 Oct 2009 23:50 I have come up with some working code, any ideas how to optimise it? function resultImg=shiftimg(a,i) imgWidth=size(a,2); imgHeight=size(a,1); xForm = [1 0 0; 0 1 0; i-imgWidth 0 1]; shiftTform = maketform('affine',xForm); resultImg = imtransform(a, shiftTform,'XData', [1 imgWidth],'YData', [1 imgHeight]);
|
Pages: 1 Prev: Runtime Error when opening Matlab 7... please HELP! Next: SimState |