I'm new here. I have a number of dicom images.
- I need to get 4 max pixel values and their co-ordinates of all the images
- and automatically crop the 128 by 128 4 patches from each image keeping the center pixel one of the max pixel that has been found
- save the patches
In this way I need to extract four patches from each pixel. Please tell me how I can do it.
I have made this code for one image but it's not giving me the right answer:
sortedValues = sort(grayImage, 'descend');
% Get the 4 max values and their coords
for k = 1 : 4
thisValue = sortedValues(k);
% Find where it occurs
[rows, columns] = find(grayImage, thisValue);
% Plot them over the image
for k2 = 1 : length(rows)
thisRow = rows(k2);
thisColumn = columns(k2);
plot(thisColumn, thisRow, 'r+');
hold on;
text(thisColumn, thisRow, num2str(k));
% Crop into a new image
row1 = thisRow - 64;
row2 = row1 + 127;
col1 = thisColumn - 64;
col2 = col1 + 127;
subImage = grayImage(row1:row2, col1:col2);
% Now do something with subimage....
end
end
Please help me.