Page 1 of 1

Identifying whether a jpg image is blank using RUBY programming

Posted: 2018-10-08T13:22:56-07:00
by rubymonk
I have an input image known as test.jpg. I want to create a function in Ruby which will identify if the image is white or close to white.(The function should incorporate some noise) and return a boolean value true or false.

Re: Identifying whether a jpg image is blank using RUBY programming

Posted: 2018-10-08T16:27:18-07:00
by fmw42
You can do the following in Imageamgick command line:

Code: Select all

convert image -threshold X% -format "%[fx:mean==1?1:0]" info:
for pure white or if you want to allow some dark noise, then change the test to

Code: Select all

convert image -threshold X% -format "%[fx:mean<=0.99?1:0]" info:
put in whatever value you want in place of 0.99 to allow for some black specs to remain after thresholding.

Sorry, I do not know Ruby. But equivalent commands should be available in RMagick or minimagick.

Re: Identifying whether a jpg image is blank using RUBY programming

Posted: 2018-10-09T09:58:55-07:00
by fmw42
Post an example image to some free hosting service such as dropbox.com that won't change the format. Then put the URL here.

My guess is that you need to do some noise filtering, such as from -morphology close.