Extracting and identifying images from a larger image

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extracting and identifying images from a larger image

Post by fmw42 »

The compare function returns a metric value. You can set a threshold on the metric as to what you think is acceptable or not.

But you should use some hash or simple image statistic such a the average color to test first against your data base, to reduce the number that have to be matched via compare.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extracting and identifying images from a larger image

Post by snibgo »

balsaboom wrote:They aren't different patterns persay, but the number of icons per picture can change (because different mobile devices have different screen resolutions). so it might be 5 rows x 5 cols or 6 rows x 5 cols.
Are the icons the same size on all the devices? If so then doesn't the width and height of the image tell you the number of rows and columns, and the location of each icon?
snibgo's IM pages: im.snibgo.com
balsaboom
Posts: 11
Joined: 2014-01-03T15:23:29-07:00
Authentication code: 6789

Re: Extracting and identifying images from a larger image

Post by balsaboom »

fmw42 wrote: But you should use some hash or simple image statistic such a the average color to test first against your data base, to reduce the number that have to be matched via compare.
Just to clarify, are you suggesting that I take a "preliminary test" and compare the average color of the icon in question to the database, then compare only to the ones that have the same average color? I would have to reupdate the average colors of the database entries if i were to add things, correct?

Thanks so much!
balsaboom
Posts: 11
Joined: 2014-01-03T15:23:29-07:00
Authentication code: 6789

Re: Extracting and identifying images from a larger image

Post by balsaboom »

snibgo wrote:
balsaboom wrote:They aren't different patterns persay, but the number of icons per picture can change (because different mobile devices have different screen resolutions). so it might be 5 rows x 5 cols or 6 rows x 5 cols.
Are the icons the same size on all the devices? If so then doesn't the width and height of the image tell you the number of rows and columns, and the location of each icon?
I'm actually unsure if they're the same size on all devices, I'll go check right now. Even if they were the same size, I'd still need to have different scripts for the different possible image input sizes, right?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extracting and identifying images from a larger image

Post by fmw42 »

I'm actually unsure if they're the same size on all devices, I'll go check right now. Even if they were the same size, I'd still need to have different scripts for the different possible image input sizes, right?
I am not sure I follow this. What does the input image size have to do with matching the icon from these images to an icon stored in a database?
balsaboom
Posts: 11
Joined: 2014-01-03T15:23:29-07:00
Authentication code: 6789

Re: Extracting and identifying images from a larger image

Post by balsaboom »

fmw42 wrote:
I'm actually unsure if they're the same size on all devices, I'll go check right now. Even if they were the same size, I'd still need to have different scripts for the different possible image input sizes, right?
I am not sure I follow this. What does the input image size have to do with matching the icon from these images to an icon stored in a database?
Depending on the image input size, the icons can be either arranged 5x5 or 5x6. Its just another way to determine which script to use. I think i'll still have the user specify which device they use at the time of upload, however.

Also: was my explanation of your previous post correct? I just want to make sure i'm getting the right idea.
balsaboom
Posts: 11
Joined: 2014-01-03T15:23:29-07:00
Authentication code: 6789

Re: Extracting and identifying images from a larger image

Post by balsaboom »

Also, would you have any idea how to invoke imagemagick through the command line through ajax? Or would I have to use php? Is it possible to write a "script" for imagemagick that the command line can execute automatically?

*edit: from what i understand, its possible to execute it from a file via bash?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extracting and identifying images from a larger image

Post by fmw42 »

Just to clarify, are you suggesting that I take a "preliminary test" and compare the average color of the icon in question to the database, then compare only to the ones that have the same average color? I would have to reupdate the average colors of the database entries if i were to add things, correct?
Yes, you would have to add fields in the database for that. Note that this is only one means of a first and fast test. Other ideas were some kind of hash, such as to reduce the image to 3x3 and save those 9 values and compare those 9 values to similar ones in the data base for the stored icons.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extracting and identifying images from a larger image

Post by fmw42 »

balsaboom wrote:Also, would you have any idea how to invoke imagemagick through the command line through ajax? Or would I have to use php? Is it possible to write a "script" for imagemagick that the command line can execute automatically?

*edit: from what i understand, its possible to execute it from a file via bash?
I have no idea whether AJAX is appropriate for calling IM. Sorry. Many APIs such as PHP, Applescript, Coldfusion support calling IM.

IM is very often run from command lines in a text file via bash unix shell script. All my scripts listed at the link below are just that. These scripts can be launched in a terminal window or on a server by using the PHP exec() command. Any API that supports something like an exec() command, such as those I listed above, can launch the script text file.
balsaboom
Posts: 11
Joined: 2014-01-03T15:23:29-07:00
Authentication code: 6789

Re: Extracting and identifying images from a larger image

Post by balsaboom »

fmw42 wrote:
balsaboom wrote:Also, would you have any idea how to invoke imagemagick through the command line through ajax? Or would I have to use php? Is it possible to write a "script" for imagemagick that the command line can execute automatically?

*edit: from what i understand, its possible to execute it from a file via bash?
I have no idea whether AJAX is appropriate for calling IM. Sorry. Many APIs such as PHP, Applescript, Coldfusion support calling IM.

IM is very often run from command lines in a text file via bash unix shell script. All my scripts listed at the link below are just that. These scripts can be launched in a terminal window or on a server by using the PHP exec() command. Any API that supports something like an exec() command, such as those I listed above, can launch the script text file.
Alright, i was just wondering if i could directly run the bash script through ajax, or whether I had to create a php file that ran the bash, then use ajax to call the php. Since there doesn't seem to be a definitive answer, I'll just go with the latter option. Thanks for all your help!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extracting and identifying images from a larger image

Post by snibgo »

basaboom wrote:I'm actually unsure if they're the same size on all devices, I'll go check right now. Even if they were the same size, I'd still need to have different scripts for the different possible image input sizes, right?
You would need to have different parameters within the script.

My theory (which you need to check) is that you don't need to know the device used. If all devices use the same size of icons and the spacing of the icons follows a simple algorithm, then you only need to know the image size to determine where all the icons are.
snibgo's IM pages: im.snibgo.com
Post Reply