Path: news.mathworks.com!not-for-mail
From: "Jeff " <jea@gene.dot.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: divide 1280-by-960 image into 9-by-9
Date: Mon, 30 May 2011 15:56:04 +0000 (UTC)
Organization: Genentech Inc
Lines: 41
Message-ID: <is0emk$jog$1@newscl01ah.mathworks.com>
References: <irm4h1$jke$1@newscl01ah.mathworks.com> <irm660$ok7$1@newscl01ah.mathworks.com> <irm7rs$lq$1@newscl01ah.mathworks.com> <irmatm$gfc$1@newscl01ah.mathworks.com> <iroa2l$pr5$1@newscl01ah.mathworks.com> <iroh3k$io4$1@newscl01ah.mathworks.com> <irp5js$htg$1@newscl01ah.mathworks.com> <irpask$131$1@newscl01ah.mathworks.com> <irtd11$267$1@newscl01ah.mathworks.com>
Reply-To: "Jeff " <jea@gene.dot.com>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1306770964 20240 172.30.248.38 (30 May 2011 15:56:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 30 May 2011 15:56:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1423763
Xref: news.mathworks.com comp.soft-sys.matlab:729311

"areeba khan" wrote in message <irtd11$267$1@newscl01ah.mathworks.com>...
> "Jeff " <jea@gene.dot.com>
> > > > > > grayimg = rgb2gray(imagein);
> > > > > > 
> > > > > > padimg = padarray(grayimg, [3 4], 0, 'post'); %modify these values to make your image dimensions divisible by 9
> > > > > > 
> > > > > > height = size(padimg,1); %height of full image
> > > > > > width = size(padimg,2); %width of full image
> > > > > > 
> > > > > > n_width = 9;
> > > > > > m_height = 9;
> > > > > > 
> > > > > > for x = 1:m_height:height
> > > > > >     for y=1:n_width:width
> > > > > >         image = bigmont(y:y+m_height-1, x:x+n_width-1);
> > > > > >         imwrite(image,strcat(num2str(x),'^',num2str(y),'.jpg'),'jpg', 'Quality',80);
> > > > > >     end
> > > > > > 
> > > > > > end
> 
> > The "Index exceeds matrix dimensions" is probably because you need to change the "3" and "4" in:
> > padimg = padarray(grayimg, [3 4], 0, 'post');
> > to give you an image with dimensions evenly divisible by 9.  
> > 
> > For example, you could make your image 963x1267 by using:
> > padimg = padarray(grayimg, [3 7], 0, 'post');
> > 
> > As far as "reducing the image"...the variable IMAGE is a 9x9 fragment of PADIMAGE that moves across the image, in a typewriter fashion, through PADIMAGE as the X and Y loops increment.  Instead of calling IMWRITE, you could assign it to individual cells in a cell array: (http://www.mathworks.com/help/techdoc/matlab_prog/br04bw6-98.html#br1zng6-1).  Does this make sense?
> 
> Jeff,
> i had done the same way as you are refering to i.e. i had changed 4 with 7 in:
> padimg line...and got the error i told you (index exceed matrix dimension)...
> and thank you..now i got about the variable image point..
> 
> do i need to reduce my image size? if yes then how?

Then you'll need to do some troubleshooting.  Make sure the image PADARRAY is being changed to the correct dimensions.  If it is, then check at what value x and y are when you get the error.

OR....

You could change your approach so that you don't have to worry about getting 9x9 image fragments, and will probably give you a more robust result.  The approach outlined by ImageAnalyst and Roger (again, outlined here:  http://www.mathworks.com/products/demos/image/cross_correlation/imreg.html ) may be a bit more complex, conceptually, but would be well worth the time to try.