Selecting sub-arrays in numeric array

2 次查看(过去 30 天)
Hey everyone,
I am working on a project that requires me to upload a RGB image to MATLAB, convert it to grayscale to extract the intensity of each pixel. However, I noticed a high number of outliers on the image. To overcome that, I want to divide it into subarrays, take their average, find the area with maximum intensity and then circle it ont the original image. At this point, I am stuck on how to divide the numeric array into subarrays automatically, meaning I would not have to do it manually everytime I upload an image with different length and width. I appreciate the help. My code is below:
PATH = 'The path for the image in your computer';
Image = imread(PATH);
BW_Image = rgb2gray(Image);
BW_Image = double(BW_Image);
figure
imshowpair(Image,BW_Image,'montage');
Max = max(BW_Image);
Min = min(BW_Image);
Maximum_Intensity_Value = max(Max);
Minimum_Intensity_Value = min(Min);
MeanValue = mean2(BW_Image);
MeanIntensityPercentage = (MeanValue/(Maximum_Intensity_Value-Minimum_Intensity_Value))*100;
[x, y] = find(BW_Image == Maximum_Intensity_Value);
Coordinates = [x, y];
T = 0:0.1:2*pi;
X = Coordinates(1,1) + 10*sin(T);
Y = Coordinates(1,2) + 10*cos(T);
figure
imshow(Image);
hold on
plot(X,Y,'w', 'LineWidth', 2);
hold off
legend('Highest Intensity Region');
fprintf(['The average intensity percentage of this image is ' num2str(MeanIntensityPercentage) '\n' 'The maximum intensity value of this image is ' num2str(Maximum_Intensity_Value)]);
  2 个评论
KALYAN ACHARJYA
KALYAN ACHARJYA 2019-11-12
In addition of Walter's hint, you can do the following-
  1. Load RGB one by one
  2. rgb2gray
  3. https://in.mathworks.com/help/images/ref/blockproc.html
  4. Find the max intensity area on the different blocks
  5. Marked
  6. Step 1
I suppose you can implement that.
Good Luck.

请先登录,再进行评论。

回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by