Selecting sub-arrays in numeric array

조회 수: 16 (최근 30일)
Ricardo Checchia Whitaker
Ricardo Checchia Whitaker 2019년 11월 12일
댓글: KALYAN ACHARJYA 2019년 11월 12일
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개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by