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
2019-11-12
In addition of Walter's hint, you can do the following-
- Load RGB one by one
- rgb2gray
- https://in.mathworks.com/help/images/ref/blockproc.html
- Find the max intensity area on the different blocks
- Marked
- 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!