Hi,
I have a big amount of pictures which I will use to do some timelapses. Well, some of them have drops of rain and I would like to apply a filter (yes, cover the camera would have been a good idea..). I think one of the best options is to use ImageMagick, but i do not know what way to choose. To my mind come several options, as using histogram on each picture ( convert picture.jpg -verbose -identify +verbose histogram:hist_picture.jpg) and configure a threshold or something like that or using spectrum/colorspectrum and also configure a threshold. I would like to know if you know any mehod that can be used to this situation and which could be the most effective. The purpose is only to conclude YES/NO DROPS for each picture.
Extra information: I am using perl scripts to do other filters and using mysql tables to save the information for each pic.
PD: cover the cameras
Detect images with drops with ImageMagick
-
- Posts: 6
- Joined: 2018-05-02T06:18:59-07:00
- Authentication code: 1152
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Detect images with drops with ImageMagick
Can you show sample images with and without drops? You can upload to anywhere on the web, and paste the URLs here.
snibgo's IM pages: im.snibgo.com
-
- Posts: 6
- Joined: 2018-05-02T06:18:59-07:00
- Authentication code: 1152
Re: Detect images with drops with ImageMagick
Yes, of course --> https://drive.google.com/drive/folders/ ... sp=sharing
Three of them are examples of pics that should not be included in the video and other two yes (first and last).
Three of them are examples of pics that should not be included in the video and other two yes (first and last).
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Detect images with drops with ImageMagick
Do edge detection and compute the density or amount of edges. Blurring from the water drops will not produce high quality edges. To compute the density of edges, you can threshold the edge detected image and then measure the average (mean) gray level in the image.
Edges can be computed in many ways: sobel, laplacian, morphology, -edge, -canny. See https://www.imagemagick.org/Usage/convolve/#edgedet
Then you pick a threshold on the mean value. If above the threshold, then no drops and if below the threshold, it has drops.
Edges can be computed in many ways: sobel, laplacian, morphology, -edge, -canny. See https://www.imagemagick.org/Usage/convolve/#edgedet
Then you pick a threshold on the mean value. If above the threshold, then no drops and if below the threshold, it has drops.
-
- Posts: 6
- Joined: 2018-05-02T06:18:59-07:00
- Authentication code: 1152
Re: Detect images with drops with ImageMagick
To summarize, thank you very much for your answers and advice.
The way you explained probably is much easier than the ones that I did.
This id what I did:
1--> convert pic.jpg -define convolve:scale='!' \
-morphology Convolve Laplacian:0 \
-auto-level pic_laplacian_positives.png
2--> convert pic_laplacian_positives.png -format "%[mean]" info:
I am not get to used to use Imagemagic and dont know if i am using the correct kernel (I will try others too, test/failure..).
Maybe there are more optimal kernels but my little knowledge don't help me.
Anyway, thankyou!!!
The way you explained probably is much easier than the ones that I did.
This id what I did:
1--> convert pic.jpg -define convolve:scale='!' \
-morphology Convolve Laplacian:0 \
-auto-level pic_laplacian_positives.png
2--> convert pic_laplacian_positives.png -format "%[mean]" info:
I am not get to used to use Imagemagic and dont know if i am using the correct kernel (I will try others too, test/failure..).
Maybe there are more optimal kernels but my little knowledge don't help me.
Anyway, thankyou!!!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Detect images with drops with ImageMagick
That is an edge detector. The result has positive and negative values, with a mean close to zero. "-auto-level" will make the result positive, with a mean close to 50%. This isn't useful for comparing images -- they will all have roughly the same mean.bekalariak wrote:-define convolve:scale='!' -morphology Convolve Laplacian:0
Edge detector values are usually small, so I suggest you should use HDRI.
Instead, you can take the absolute value of the edge detector ("-evaluate Abs 0"). This leaves positive values alone, and makes negative values positive. Then you can take the mean, and comparisons of means between images is meaningful.
Code: Select all
magick -precision 16 toes.png -define convolve:scale="!" -morphology Convolve Laplacian:0 -evaluate Abs 0 -format %[fx:mean] info:
0.008843092928576947
snibgo's IM pages: im.snibgo.com