From: Ashish Uthama on
On Fri, 16 Apr 2010 15:35:41 -0300, Nghia Le <nghiatle(a)gmail.com> wrote:

> Hi, what I am trying to do is to identify the tumor, normal, or
> background region by using the wavelet transform on each block to obtain
> mean and std for each component. After that I will form a ID matrix and
> use classify function for computer learning process.

I dont see why you cant use BLOCKPROC for this.

For example, to obtain the mean of each block:

>> I=magic(20);
>> blockMeans= blockproc(I,[5 5],@(bs)mean(bs.data(:)))

blockMeans =

205.1200 195.9200 196.2800 204.6800
196.6800 204.2800 203.9200 197.1200
203.8800 197.0800 196.7200 204.3200
196.3200 204.7200 205.0800 195.8800

You could replace the third argument with a function handle to perform
wavelet transform etc.



> Concerning your suggestion, I did try the third loop many times and
> trials, but the output for all A(:,:1), A(:,:,2), A(:,:,3)... is the
> identical matrix. I am sure there is a simple fix for this, but I do not
> know how to do it. I will keep posted.

Posting code might help CSSMers point out what might need to be corrected.
From: Nghia Le on
Yes I also tried this, but the problem is that dtw2 has [cA,cH,cV,cD] components, I am having trouble defining a function handle that will take mean or std for each component by using blockproc.

"Ashish Uthama" <first.last(a)mathworks.com> wrote in message <op.va9qda0ua5ziv5(a)uthamaa.dhcp.mathworks.com>...
> On Fri, 16 Apr 2010 15:35:41 -0300, Nghia Le <nghiatle(a)gmail.com> wrote:
>
> > Hi, what I am trying to do is to identify the tumor, normal, or
> > background region by using the wavelet transform on each block to obtain
> > mean and std for each component. After that I will form a ID matrix and
> > use classify function for computer learning process.
>
> I dont see why you cant use BLOCKPROC for this.
>
> For example, to obtain the mean of each block:
>
> >> I=magic(20);
> >> blockMeans= blockproc(I,[5 5],@(bs)mean(bs.data(:)))
>
> blockMeans =
>
> 205.1200 195.9200 196.2800 204.6800
> 196.6800 204.2800 203.9200 197.1200
> 203.8800 197.0800 196.7200 204.3200
> 196.3200 204.7200 205.0800 195.8800
>
> You could replace the third argument with a function handle to perform
> wavelet transform etc.
>
>
>
> > Concerning your suggestion, I did try the third loop many times and
> > trials, but the output for all A(:,:1), A(:,:,2), A(:,:,3)... is the
> > identical matrix. I am sure there is a simple fix for this, but I do not
> > know how to do it. I will keep posted.
>
> Posting code might help CSSMers point out what might need to be corrected.
From: Ashish Uthama on
On Thu, 15 Apr 2010 22:59:04 -0300, Nghia Le <nghiatle(a)gmail.com> wrote:

> Hi, I am new to medical imaging analysis and matlab. Here is what I am
> trying to solve, hope you can provide me some guidance:
> I am trying to segment an image into smaller blocks and analyze data
> those blocks individually. For example, I have a 20x20 image
> (grayscale) and I want to segment into four blocks and form a
> 3-dimensional matrix 5x5x16 that I call 'A' by using for loop and here
> is my test code:
>
> I=magic(20);
> for m=1:4;
> for n=1:4;
> vl=(m-1)*5+1;
> vh=(m-1)*5+5;
> hl=(n-1)*5+1;
> hh=(n-1)*5+5;
>
> A(:,:,:)=I(vl:vh,hl:hh)
> end
> end
>
> Here is my problem, I cannot get A to define in term of m and n. For
> example if I want to view block A(m=1 and n=3) it would show up
> I(1:5,11:15). I been searching for the correct code two days and yet to
> find the solution. Hope you can provide some guidance. Thank you in
> advanced.

Probably not the most elegant of solutions:


I=reshape(1:400,[20 20]);
A=zeros(5,5,16);
[cGrid rGrid] = meshgrid(1:5:20);

for thirdInd = 1:16
A(:,:,thirdInd)=I(rGrid(thirdInd):rGrid(thirdInd)+4,...
cGrid(thirdInd):cGrid(thirdInd)+4 );
end
From: Nghia Le on
Thank you, everything works like a charm. You're the best.



"Ashish Uthama" <first.last(a)mathworks.com> wrote in message <op.va9uwbk9a5ziv5(a)uthamaa.dhcp.mathworks.com>...
> On Thu, 15 Apr 2010 22:59:04 -0300, Nghia Le <nghiatle(a)gmail.com> wrote:
>
> > Hi, I am new to medical imaging analysis and matlab. Here is what I am
> > trying to solve, hope you can provide me some guidance:
> > I am trying to segment an image into smaller blocks and analyze data
> > those blocks individually. For example, I have a 20x20 image
> > (grayscale) and I want to segment into four blocks and form a
> > 3-dimensional matrix 5x5x16 that I call 'A' by using for loop and here
> > is my test code:
> >
> > I=magic(20);
> > for m=1:4;
> > for n=1:4;
> > vl=(m-1)*5+1;
> > vh=(m-1)*5+5;
> > hl=(n-1)*5+1;
> > hh=(n-1)*5+5;
> >
> > A(:,:,:)=I(vl:vh,hl:hh)
> > end
> > end
> >
> > Here is my problem, I cannot get A to define in term of m and n. For
> > example if I want to view block A(m=1 and n=3) it would show up
> > I(1:5,11:15). I been searching for the correct code two days and yet to
> > find the solution. Hope you can provide some guidance. Thank you in
> > advanced.
>
> Probably not the most elegant of solutions:
>
>
> I=reshape(1:400,[20 20]);
> A=zeros(5,5,16);
> [cGrid rGrid] = meshgrid(1:5:20);
>
> for thirdInd = 1:16
> A(:,:,thirdInd)=I(rGrid(thirdInd):rGrid(thirdInd)+4,...
> cGrid(thirdInd):cGrid(thirdInd)+4 );
> end