# How do I find the local maxima near already specified points on an image?

1 view (last 30 days)
Julie Abernathy on 29 Jan 2021
Edited: Iuliu Ardelean on 29 Jan 2021
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.

Iuliu Ardelean on 29 Jan 2021
Edited: Iuliu Ardelean on 29 Jan 2021
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:
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, ); % you could use also rgb2gray instead
whitest_pixel_value = max(greyscale_region_of_interest, [], 'all')