Borrar filtros
Borrar filtros

Find light grey circle in greyscale image

10 visualizaciones (últimos 30 días)
Benedikt Thomann
Benedikt Thomann el 2 de Dic. de 2022
Editada: Stephan el 8 de Dic. de 2022
Dear community,
I have a problem finding a circle in a greyscale image.
The image was taken with an X-ray scanner, through a circular shaped aperture and contains a ball/circle, approximately in the center of this aperture. I want to find the aperture circle and the (smaller) circle for the ball. I know the approximate radius, so I am specifying a range of radii to look for (since I have other circles in the image that I do not want to find).
The reason I am doing this is to exactly find the centers of these circles in order to evaluate whether the ball was placed at the exact center of the imager. I have a working code that does so, see example below.
Now to the problem:
I now have other images in which the images ball is of a different material and hence not as dark in the image. Unfortunately, I can't find a way to make my current code work for this "light grey" circle.
info = dicominfo('Gantry3-003.dcm');
img = dicomread(info);
img_BW = imbinarize(img,'adaptive','ForegroundPolarity','dark','Sensitivity',1);
SID = info.RTImageSID;
SSD = info.RadiationMachineSAD;
pxlsize_mm = info.ImagePlanePixelSpacing(1) /SID *SSD;
angle_Gantry = round(info.GantryAngle);
angle_Colli = round(info.BeamLimitingDeviceAngle);
angle_Table = round(info.PatientSupportAngle);
h = figure('Position', [2000, 100, 1400, 1000]);
[centersDark,radiiDark] = imfindcircles(img_BW,[10 20], ...
'ObjectPolarity','dark', 'Sensitivity',0.8);
[centersBright,radiiBright] = imfindcircles(img_BW,[20 30], ...
numcirclesDark = length(centersDark)/2;
numcirclesBright = length(centersBright)/2;
hDark = viscircles(centersDark,radiiDark);
hBright = viscircles(centersBright, radiiBright,'Color','b');
This is the result (original image on the left, processed image with found circles on the right):
For the new image with a lighter colored ball in the center, it looks like this - I don't find this circle:
Unfortunately, I cannot attach dicom images, so I attached the images given above.
Any help would be greatly appreciated!
Also: If there is a simpler or better solution for my problem in general - feel free to comment! ;)
Thank you very much,
  1 comentario
Benedikt Thomann
Benedikt Thomann el 2 de Dic. de 2022
I forgot to mention:
I realize that my problem stems from binarizing the image. I am binarizing the image so that it is easier to find the circles. If there is any other/better way, any help would be welcome!

Iniciar sesión para comentar.

Respuesta aceptada

Stephan el 2 de Dic. de 2022
Editada: Stephan el 2 de Dic. de 2022
Maybe this is an approach:
img = imread('BinarizedImage_NewImage.JPG');
img2 = img;
img2(img2<240) = 0;
result is attached. The value 240 appears to work good - 235 gives similar results. You should play with the values. Once you have a suitable value, you can use imfindcircles as always.
  7 comentarios
Benedikt Thomann
Benedikt Thomann el 7 de Dic. de 2022
Editada: Benedikt Thomann el 7 de Dic. de 2022
Thank you for your comment. I think my last question was a little bit misleading.
I am not concerned about the two images in my last comment not being perfectly aligned. That was merely a screenshot from the plot I am generating in my script to see the original and the edited image. I do not know why they are not perfectly aligned but I do not see any real problem in that either as all I want to do is compare the two centers of the found circles relative to each other.
My real problem was that to me it looks as if the inner black circle was somehow further away from the center than the light grey circle in the original image. But maybe it's just my eyes or some kind of illusion. I don't see any reason why it should "move". Tha data shouldn't lie. :)
Despite of that: I am indeed interested in the double thresholding solution you mentioned to maybe increase accuracy in terms of circles found.
Unfortunately, I cannot add dicom files, or can I?
Stephan el 7 de Dic. de 2022
Editada: Stephan el 8 de Dic. de 2022
@Image Analyst Im also interested in an alternative - probably more exact solution - to this.

Iniciar sesión para comentar.

Más respuestas (0)




Community Treasure Hunt

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

Start Hunting!

Translated by