Matlab algorithm for finding ROI

조회 수: 2 (최근 30일)
Ciara
Ciara 2014년 4월 4일
댓글: Image Analyst 2014년 4월 5일
Would anyone be able to help me code my algorithm:
WHILE entire image has not been examined by 16 16 window
MOVE 16 16 window to next position
RECORD position and grey level value of pixel with
largest grey level in window
IF pixels surrounding the largest pixel are as bright as the
largest pixel grey level value
AND outer pixels are darker than the largest pixel grey
level value
THEN largest pixel position is the center pixel of a microcalcification
area
END IF
END WHILE
I have done the first dour lines of the algorithm as follows but I am confused about the coding for the rest of it.
N = 16;
info = repmat(struct, ceil(size(Z, 1) / N), ceil(size(Z, 2) / N)); %creates an array of structs consisting of an m-by-n tiling
for row = 1:N:size(Z, 1)%loop through each pixel in the image matrix
for col = 1:N:size(Z, 2)
r = (row - 1) / N + 1;% store the row index for each window
c = (col - 1) / N + 1;%store the col index for each window
imgWindow = Z(row:min(end,row+N-1), col:min(end,col+N-1));
largest = max(imgWindow(:));
[rLarg, cLarg] = find(imgWindow == largest, 1, 'first');
window(r, c).largest = largest;
window(r, c).row = rLarg + row - 1;
window(r, c).col = cLarg + col - 1;
end
end
Any help or guidance would really be appreciated! Thanks!
  댓글 수: 5
Joseph Cheng
Joseph Cheng 2014년 4월 5일
편집: Joseph Cheng 2014년 4월 5일
well from the pseudocode he/she is looking for just the max/"brightest" in the 16x16 block window. If "we" take the current 16x16 and am looking for only the max values and have blobs then it should work. However i do see the case where the blob is in the shape of a doughnut.
I haven't dealt with mammogram images for a while but given it's an X ray the center of the calcification deposit probably has the highest density in the center. In the original post by the user you did suggest to dialate and fill right?
Image Analyst
Image Analyst 2014년 4월 5일
The code creates an array of structures. For each pixel, there is a structure that holds the max gray level and the location of that pixel relative to the center. So the code does not do what the algorithm spells out and ends up with an array of structures that I don't know what to do with. So now we have two mysteries (1) was the algorithm relayed correctly, and (2) what does his algorithm do, since it doesn't do the algorithm and ends up with something that is not used and we don't know what to do with.

댓글을 달려면 로그인하십시오.

답변 (1개)

Joseph Cheng
Joseph Cheng 2014년 4월 4일
편집: Joseph Cheng 2014년 4월 4일
Here is an example of what you can do to determine the surroundings using convolution.
x= randi(5,16,16); %generate random 16x16 image
x(4:8,7:9)=20; %make portion of it bright
X=[x(:,1) x x(:,end)]; %Pad column.
PaddedX=[X(1,:);X;X(end,:)]; %pad it again for rows
Nmask = [0 1 0;1 1 1;0 1 0]; % Convolution mask for neighbors.
Check = conv2(PaddedX,Nmask/5,'valid'); %here conv will place the mask over the now 18x18 image and element by element multiply this against the 3x3 it is over and add the result. in the Check.
[r c]= find(Check == max(x(:))) %find the row and column index for where check equals the max value of the 16x16 block.
As you can see the convolution mask is a + sign which when element by element multiplied and summed and divide by 5. you are basically checking to see if the average of the pixels surrounding the center point is. I'll leave it to you to play around with this to see how you can use a similar approach to check the pixel surroundings

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by