-1

I have an input image known as test.jpg. I want to create a function in Ruby which will identify if the image is blank and return a boolean value true or false.

1 Answers1

2

In Imagemagick 6 command line, one could do the following. Threshold the image, then use fx to test if the mean is equal to 1 (full white). If so, return 1, else return 0.

convert image -threshold X% -format "%[fx:mean==1?1:0]" info:


Sorry, I do not know ruby.

fmw42
  • 46,825
  • 10
  • 62
  • 80
  • Actually converting this to ruby should not be very difficult take a look at [`mini_magick`](https://github.com/minimagick/minimagick). It leverages the CLI for ImageMagick and offers direct access to the [raw attributes](https://github.com/minimagick/minimagick#attributes). – engineersmnky Oct 08 '18 at 18:00
  • @fmw42 , can we incorporate some noise in the image. As in if there are a few dots in the image, can it still assign it as full white . In this command, if there are a few dots on the image it assigns it as 0 – Yash Madane Oct 08 '18 at 19:33
  • If the dots have gray level above your threshold, then it should still work. Otherwise change the test to mean<=.99 or whatever value you want to consider as a degradation from white. – fmw42 Oct 08 '18 at 23:25