Dear Everybody,
I applied some image processing technics in order to get a more focussed configuration.
I get something like this:
This photo consist of a matrix of 0 (black) and 1 (white).
My objective is identify all the white circles and to fill them with white color (transform 0's to 1's).
Do you think it is possible to detect the circles and then do this action?
Thanks a lot ofr your help.
Krs,
Samir
Firstly that image contains open circles, how would you handle that, or just lines?
SAS wouldn't be the way I would choose to do this.
What I would do is this (and you may be able to batch mode this):
Get a proper image editing package - GIMP for instance.
Use this package to create another layer to the image, fill the image with white - i.e. so the circles would still be black but everything else would be white.
Use the two layers to create a merged image, i.e. if black in base layer, and black in top layer then black, if black in top layer then black, else white. Maybe mask top as white is transparent:
https://docs.gimp.org/en/gimp-image-merge-layers.html
However this is outside the scope of this forum.
I think this is a difficult task. There have been research papers written in computational geometry and computer vision that address this kind of problem, but there are mathematical as well and computational issues.
There are a few reasons it is hard. First, the pixels are discrete, so you have to define rules for recognizing a closed polygon when the edges are pixels. Second, it is not clear what is inside or outside. Third, this is a problem of global geometry, not local geometry.
For the first problem, consider the following region:
010
101
010
You would have to define a rule whether to change the middle cell to white,
Second, consider the following pixels:
11111111111
1001001001
1001111001
1000000001
11111111111
These pixels approximate a self-intersecting loop, but also two nested circles, like this
It is not clear which zeros should be changed to 1s.
The situation is even worse when some of the pixels touch the boundary, as yours do. Then it is not clear where the INSIDE of the curve is. For example, can you find the inside of the inside of the following image?
In summary, I think you should discuss this problem with a computer scientist who might know if there is specialized software. I suspect it will be daunting to write an algorithm yourself in a general-purpose language like SAS/IML.
Firstly that image contains open circles, how would you handle that, or just lines?
SAS wouldn't be the way I would choose to do this.
What I would do is this (and you may be able to batch mode this):
Get a proper image editing package - GIMP for instance.
Use this package to create another layer to the image, fill the image with white - i.e. so the circles would still be black but everything else would be white.
Use the two layers to create a merged image, i.e. if black in base layer, and black in top layer then black, if black in top layer then black, else white. Maybe mask top as white is transparent:
https://docs.gimp.org/en/gimp-image-merge-layers.html
However this is outside the scope of this forum.
Firstly that image contains open circles, how would you handle that, or just lines?
SAS wouldn't be the way I would choose to do this.
What I would do is this (and you may be able to batch mode this):
Get a proper image editing package - GIMP for instance.
Use this package to create another layer to the image, fill the image with white - i.e. so the circles would still be black but everything else would be white.
Use the two layers to create a merged image, i.e. if black in base layer, and black in top layer then black, if black in top layer then black, else white. Maybe mask top as white is transparent:
https://docs.gimp.org/en/gimp-image-merge-layers.html
However this is outside the scope of this forum.
This tends to be a very sophisticated problem, not easily soled by a non-programming(EG server) oriented system like SAS.
I have poseted a python maze image soltion in SAS-L. However I would investigate
http://www.pyimagesearch.com/2014/07/21/detecting-circles-images-using-opencv-hough-circles/
for circles.
I think it is doable in python. I have also posted an interface to python from SAS. As a side note WPS has a python interface. I don't think SAS should waste resources on image processing because Python has easly usable packages?
Dear Everybody,
Thanks a lot for your suggestions.
I will do some investigations according to your replies and go back to you.
Have a nice day,
Samir
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.