How do I find the local maxima near already specified points on an image?
2 次查看(过去 30 天)
显示 更早的评论
I'm designing an image analysis application which analyzes an image to determine significant points, then plots the predetermined points onto a different image. I now want to find the local maximum pixel values near each of these points, or I would like to average some amount of pixels surrounding these points to get one value from each point. What is the best way to go about this?
Note: The pixel values near these points are not neccesarily maxima values in terms of the whole image, some of these values may even be near zero.
0 个评论
回答(1 个)
Iuliu Ardelean
2021-1-29
编辑:Iuliu Ardelean
2021-1-29
Each image is a matrix. An RGB image is a 3d matrix of size (height, width, depth). The depth will be 3, i.e. red, green and blue.
If you know the coordinates of your points of interest, you can simply select those elements in the matrix around that point, like this:
m = imread('peppers.png');
imshow(m)
% get a point of interest (poi)
x = 250;
y = 250;
sides = 30;
region_of_interest = m(x-sides:x+sides, y-sides:y+sides, :);
imshow(region_of_interest)
% average pixel colour as an RGB triplet
average_pixel_colour = mean(region_of_interest, [1 2])
% if you want the whitest pixel value, then this may be what you are looking for:
greyscale_region_of_interest = mean(region_of_interest, [3]); % you could use also rgb2gray instead
whitest_pixel_value = max(greyscale_region_of_interest, [], 'all')
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!