Selecting sub-arrays in numeric array

17 vues (au cours des 30 derniers jours)
Ricardo Checchia Whitaker
Ricardo Checchia Whitaker le 12 Nov 2019
Commenté : KALYAN ACHARJYA le 12 Nov 2019
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 commentaires
KALYAN ACHARJYA
KALYAN ACHARJYA le 12 Nov 2019
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by