Identify Different Types of Images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Vanns
Posts: 11
Joined: 2016-08-29T05:28:51-07:00
Authentication code: 1151

Identify Different Types of Images

Post by Vanns »

I am having images in different formats like screenshots, images having handwritten/lines/shapes and pictures (nature/person/animal). How to identify them individually. Is there any way to do that?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identify Different Types of Images

Post by fmw42 »

This post was not relevant to the topic. So I have moved it and changed the title.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identify Different Types of Images

Post by snibgo »

Vanns wrote:Is there any way to do that?
There are various techniques for identifying whether a photo contain people or animals etc. These are not simple techniques, and often involve "training" a system.

For identifying whether the image is a screenshot, or hand-written shape, or photo, the process may be simpler. Do you have example images?
snibgo's IM pages: im.snibgo.com
Vanns
Posts: 11
Joined: 2016-08-29T05:28:51-07:00
Authentication code: 1151

Re: Identify Different Types of Images

Post by Vanns »

Picture is
Image

Screenshot is
Image

Line drawing is
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identify Different Types of Images

Post by snibgo »

Code: Select all

%IM%convert screenshot-gimp-windowsvista.png -statistic standard-deviation 3x3 -grayscale Brightness -fill White +opaque Black -negate -format %[fx:mean] info:
0.337484
So about one-third of the screenshot is flat colour. For the line drawing, about 63%. For the photo, only 1%.

(Photos have virtually no areas of flat colour.)

The third image is grayscale with a very high mean (96%).
snibgo's IM pages: im.snibgo.com
Vanns
Posts: 11
Joined: 2016-08-29T05:28:51-07:00
Authentication code: 1151

Re: Identify Different Types of Images

Post by Vanns »

For what parameter this value is evaluated? Can u please explain the command?

One third of the screenshot mean its size or?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identify Different Types of Images

Post by snibgo »

%IM%convert screenshot-gimp-windowsvista.png : read the image.

-statistic standard-deviation 3x3 : for every pixel, for each colour channel, calculate the standard deviation of a 3x3 square centred on the pixel. Where we have a flat colour, all pixels are the same, so SD=0.

-grayscale Brightness : find the largest of all the colour channels.

-fill White +opaque Black : where a pixel isn't black, make it white. So any pixels with any SD > 0 will become white.

-negate : makes black into white and white into black. Now, any pixels with any SD > 0 will be black. Pixels with all SD=0 are white.

-format %[fx:mean] info: : Find the mean. As all pixels are either black or white, this is the proportion of pixels that are white.

So the answer, 0.337484, means that one-third of the pixels are the centre of 3x3 pixel squares where all 9 pixels are the same colour.
snibgo's IM pages: im.snibgo.com
Vanns
Posts: 11
Joined: 2016-08-29T05:28:51-07:00
Authentication code: 1151

Re: Identify Different Types of Images

Post by Vanns »

But when I tried with my laptop's screenshot, it is showing 0.886308

It is not around 0.33. What could we do in these cases?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identify Different Types of Images

Post by snibgo »

Photos will have virtually no areas of flat colour, around 0.01. Screenshots and line drawing will have much higher numbers, perhaps between 0.1 and 1.0.
snibgo's IM pages: im.snibgo.com
Vanns
Posts: 11
Joined: 2016-08-29T05:28:51-07:00
Authentication code: 1151

Re: Identify Different Types of Images

Post by Vanns »

How to make difference between screenshot and line drawings depending upon this value?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identify Different Types of Images

Post by snibgo »

I don't understand the question.
snibgo's IM pages: im.snibgo.com
Vanns
Posts: 11
Joined: 2016-08-29T05:28:51-07:00
Authentication code: 1151

Re: Identify Different Types of Images

Post by Vanns »

Can u help me with jmagick function calls for the same command?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identify Different Types of Images

Post by snibgo »

Sorry, I don't use jmagick.
snibgo's IM pages: im.snibgo.com
karlw
Posts: 5
Joined: 2016-10-12T01:35:48-07:00
Authentication code: 1151

Re: Identify Different Types of Images

Post by karlw »

Vanns wrote:But when I tried with my laptop's screenshot, it is showing 0.886308

It is not around 0.33. What could we do in these cases?
you not screen your wallpaper or open graphic program in case?
coz your example for screenshot is actualy 50% "Picture" and 50% drawed windows.
i'm affraid screenshot what guis tok about is open Exel or World.
sandy
Posts: 1
Joined: 2016-10-21T03:38:34-07:00
Authentication code: 1151

Re: Identify Different Types of Images

Post by sandy »

convert screenshot-gimp-windowsvista.png -statistic standard-deviation 3x3 -grayscale Brightness -fill White +opaque Black -negate -format %[fx:mean] info:
0.337484
Can we find out the same value using jmagick?
Post Reply