Identifying bright spots in RGB image

I have hundreds of RGB images (one of the image is attached). For reference these are interference images and the RGB color values correspond to certain film thickness between a semi reflective glass surface and a steel surface. I apply electric potential across the surface and observed electric discharges which show as bright spots on the image (highlighted in red circle in attached image).
I want to write a script in MATLAB (2023a) that goes through the images, identify these bright spots stores there location in the XY cordinate system. The end goal is to show spatial distribution of the electric discharges.

3 commentaires

Walter Roberson
Walter Roberson le 15 Avr 2026 à 17:47
Question: Is there always exactly zero or one bright spots to be detected, or do some images have multiple bright spots?
dpb
dpb le 15 Avr 2026 à 18:44
Second Q: Are these spots guranteed to be in the general background color area of the example? The difficulty in discerning differences is going to be very tough or completely impossible in some areas of the image.
I'd guess adding a few more "typical" images might be beneficial.
Ammad Yousuf
Ammad Yousuf le 15 Avr 2026 à 19:40
Thank you for your response.
  1. There can be multiple spots of approximately same intensity.
  2. The backgorund color would change as the film thickness changes. But based on the physics behind, they have higher probability of occuring in the two lobe regions.
I am adding more images showing these spots.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 15 Avr 2026 à 19:13

1 vote

If the spots are always about the same size and white, then you can just segment out white regions and then filter out things that are not small and round.
Convert to HSI color space
  1. Threshold the S channel to find bright, neutral colored regions.
  2. Call bwareafilt() to extract out things in the desired size range.
  3. Call regionprops to get the Centroid and Bounding Box or roundness.
  4. Compute aspect ratio and get rid of things that are not round.
Let me know if you need help figuring it out. Attach more images also.

6 commentaires

Ammad Yousuf
Ammad Yousuf le 15 Avr 2026 à 19:41
Thank you for your kind response. The spots are of approximately same size and white. Can I use RGB data or should I convert to HSI color space?
Image Analyst
Image Analyst le 15 Avr 2026 à 21:40
It depends on if the white spots are all about the same intensity. If they are you can do it in RGB space just thresholding each color channel independently and ANDing the binary images together. If they have varying brightnesses, then convert to HSI space because that will let you find all neutral colored regions regardless of what intensity they are.
Ammad Yousuf
Ammad Yousuf le 16 Avr 2026 à 16:42
Modifié(e) : Ammad Yousuf le 16 Avr 2026 à 17:02
I tried it with RGB image and in HSI color sapce but could not get the desired result. Because these spots are very subtle and the background color can change I am really stuck with this.
Is it possible to convert the RGB image to grayscale and use edge detection, but I don't have much experience or knowledge with this. I have attached some images and one in grayscale. With this I dont need to determine the circularity or aspect ratio.
Thank you for your help.
dpb
dpb le 16 Avr 2026 à 18:33
Those are the sort of thing I was envisioning that are going to be extremely difficult to pick out, I suspect. I doubt edge detection is going to be of much help there, there really isn't any edge to detect.
It's probably too late, but I'd think taking the images through a filter initially might have helped....or a thermal instead of visual image, maybe?
I suggest you try a tophat filter. It's meant for this kind of object. Get SE with strel using a disc of radius 1, 2, or 3 or whatever is best.
help imtophat
imtophat - Top-hat filtering This MATLAB function performs morphological top-hat filtering on the grayscale or binary image I using the structuring element SE. Syntax J = imtophat(I,SE) J = imtophat(I,nhood) Input Arguments I - Input image grayscale image | binary image SE - Structuring element strel object | offsetstrel object nhood - Structuring element neighborhood matrix of 0s and 1s Output Arguments J - Top-hat filtered image grayscale image | binary image Examples openExample('images/UseTophatFilteringToCorrectUnevenIlluminationExample') See also imclose, imdilate, imerode, imopen, imbothat Introduced in Image Processing Toolbox before R2006a Documentation for imtophat doc imtophat Other uses of imtophat gpuArray/imtophat
Thank you for the suggestion. I managed to write the following script with the results attached. It manages to identify the spots in most of the cases (sample 2 and sample 3) but fails in some instances (for example Sample 1 attached). After analysing 464 frames I get the results shown in the fourth image. I have also attached the raw .bmp image in which the script failed to detect the spot in case you want to analyse it yourself. Running the script on this image worked in R2025a but not in R2023a.
%[file,path]= uigetfile('*.bmp'); f_p= [path,file];
img= imread('3652.bmp');
img_gray= rgb2gray(img);
SE= strel('disk',24);
img_gray= imtophat(img_gray,SE);
BW= edge(img_gray,'Canny');
BW_fill = bwareaopen(imfill(BW,'holes'),20);
BW_filt= bwareafilt(BW_fill,[30,50]);
stats= regionprops(BW_filt,'Area','Perimeter','Centroid');
numRegions= numel(stats);
circularCentroids= [];
circularity_threshold= 0.75;
for k=1:numRegions
A= stats(k).Area; P= stats(k).Perimeter;
circularity = (4*pi*A)/(P^2);
if circularity > circularity_threshold
x_c= stats(k).Centroid(1); y_c= stats(k).Centroid(2);
circularCentroids = [circularCentroids;x_c,y_c];
end
end
figure();
subplot(1,3,1);
imshow(img);
title('Original Image');
subplot(1,3,2);
imshow(BW_filt);
title('Threshold Region');
subplot(1,3,3);
imshow(img);
hold on
if ~isempty(circularCentroids)
plot(circularCentroids(:,1),circularCentroids(:,2),'r.','MarkerSize',15);
end
hold off
title('Identified spots');

Connectez-vous pour commenter.

Catégories

Produits

Version

R2023a

Question posée :

le 15 Avr 2026 à 17:13

Commenté :

il y a environ 6 heures

Community Treasure Hunt

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

Start Hunting!

Translated by