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: Thu, 26 May 2011 19:50:14 +0000 (UTC)
Organization: Genentech Inc
Lines: 62
Message-ID: <irmatm$gfc$1@newscl01ah.mathworks.com>
References: <irm4h1$jke$1@newscl01ah.mathworks.com> <irm660$ok7$1@newscl01ah.mathworks.com> <irm7rs$lq$1@newscl01ah.mathworks.com>
Reply-To: "Jeff " <jea@gene.dot.com>
NNTP-Posting-Host: www-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1306439414 16876 172.30.248.48 (26 May 2011 19:50:14 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 26 May 2011 19:50:14 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1423763
Xref: news.mathworks.com comp.soft-sys.matlab:728912

"areeba khan" wrote in message <irm7rs$lq$1@newscl01ah.mathworks.com>...
> "Jeff " <jea@gene.dot.com> wrote in message <irm660$ok7$1@newscl01ah.mathworks.com>...
> > "areeba khan" wrote in message <irm4h1$jke$1@newscl01ah.mathworks.com>...
> > > i am working on a project detection of skin cancer using image processing..i have found a reference matrix of 9-by-9 of tumourous cell now through looping i want 2 compare this reference matrix with the image...   bt my program is giving this error                                                        
> > > ??? Error using ==> mat2cell
> > > Number of input vector arguments, 9, does not match the input matrix's number of dimensions, 2. 
> > > this is my code
> > > i=imread('E:\cancer images\case 091610\20X1.jpg');
> > > a=rgb2gray(i);
> > > b=imadjust(a);
> > > v=MAT2CELL(b,1,2,3,4,5,6,7,8,9);
> > > mat1=b(725:733,231:239);
> > > c=mat1;
> > > for t=1:size(c,2)
> > >     for u=1:size(c,1)
> > >         y=xcorr(c(:),b(:));
> > >        if y>=0.7
> > >            disp('Tumor detected')
> > >            else
> > >            disp('tumor not found')
> > >        end
> > >     end
> > > end
> > > please tell me if i am doing right?
> > > tell me some way how i can divide the real image 1280-by-960 into 9-by-9?
> > 
> > Well, you're getting an error, so I'm going to go out on a limb and say you're not doing it right.  ;)
> > 
> > If you had an 18x18 pixel image, and wanted to break it into 4 9x9 cells, you could use the mat2cell command:
> > b= magic(18);
> > c = mat2cell(b, [9 9], [9 9]);
> > 
> > But what you want is probably more along the lines of the blockproc function (http://www.mathworks.com/help/toolbox/images/ref/blockproc.html).
> 
> as far as i get it, the use of magic command doesn't seem to be relevant for my task..can u please guide me how can i divide/break the 960-by-1280 image into 9-by-9 cells?

Did you look at the blockproc function?  Particularly the example at:
http://www.mathworks.com/help/toolbox/images/f7-12726.html#brcu20d-1
You can call your comparison metric as the function, but getting your raw image and index into the same image may be tricky.

Failing that, you'll first need to figure out what you want to do with the remainders, since 9 is not evenly divisible into 960 nor 1280.  I would suggest using padarray.

After you have something that is evenly divisible, take a look at the code below.  It performs an arbitrary operation, imwrite, where you would want to put your comparison:

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