Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
google site



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-06-2009
Registered User
 

Join Date: Dec 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Using grep to compare JPEGs

Hi, I'm not sure if this is the right place but I'm a newb so it seemed right. I'm trying to write some code to organize JPEGs. Its a long story, but essentially, I need the program to tell me whether a particular jpeg is of 1) a sheet of paper (lets say its solid pink that takes up the entire frame) or 2) whether the image is of anything other than a piece of pink paper.

I assumed I would need to learn something like Python to do the comparison, but a friend suggested that I use the UNIX "grep" command. The problem I'm having is finding any string that represents "pink." Can anyone help me out?
Sponsored Links
  #2  
Old 12-06-2009
DukeNuke2's Avatar
Soulman
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 3,528
Thanks: 1
Thanked 8 Times in 8 Posts
i don't think that "grep" is the right tool for you... and maybe no "scripting" language is. but i don't know python or other "higher" languages.
  #3  
Old 12-06-2009
pludi's Avatar
pludi pludi is online now Forum Staff  
Moderator
 

Join Date: Dec 2008
Location: Sqrt[-e^(-2 i Pi)]
Posts: 3,789
Thanks: 1
Thanked 63 Times in 60 Posts
JPEGs are binary data, there is no string in there representing pink. There are only the discreet transformations for each pixel and color (Red, Green, Blue), so unlike bitmaps, you can't even determine the color by looking at a certain position without decoding it first. Also, if you want to know more that just if an image contains "pink", you'll have to do image/pattern recognition.

grep, on the other hand, is intended to handle plain text (in various encodings if possible), and wouldn't even know what to do with pictures.
  #4  
Old 12-07-2009
fpmurphy's Avatar
Moderator
 

Join Date: Dec 2003
Location: /dev/eou
Posts: 2,385
Thanks: 0
Thanked 21 Times in 20 Posts
Interesting question. You could use jpegtopnm (part of the netpbm toolkit) to convert to PPM Type 3 format and then write a script to check the contents using some sort of heuristics such as CCL (connected component labeling)
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to grep and compare timestamp in a file with the current date achu AIX 1 05-25-2009 09:05 AM
how to grep and compare timestamp in a file with the current date achu AIX 1 05-25-2009 08:20 AM
how to grep and then to compare ravi18s Shell Programming and Scripting 5 05-15-2009 06:38 AM
Compare 2 array files using grep lanna001 UNIX for Dummies Questions & Answers 2 04-22-2009 09:32 AM
compare grep? k@ssidy UNIX for Dummies Questions & Answers 7 06-15-2005 11:59 AM



All times are GMT -4. The time now is 07:51 AM.