cropping color bars from manuscript 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
jimgreer
Posts: 3
Joined: 2016-01-22T11:01:51-07:00
Authentication code: 1151

cropping color bars from manuscript images

Post by jimgreer »

I'm looking for some help with a fancy crop. I'm trying to cut the colorbar section (and the black area) out of manuscript images like this one: http://i.imgur.com/Us88XsY.jpg.

(I'm using version 6.9.3-0 Q16 on a Mac)

Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: cropping color bars from manuscript images

Post by fmw42 »

Is the color bar and black area always the same width and position?
jimgreer
Posts: 3
Joined: 2016-01-22T11:01:51-07:00
Authentication code: 1151

Re: cropping color bars from manuscript images

Post by jimgreer »

Not exactly - I was hoping for something that would just crop the black and color bar section and black based on color. Seems like that may be pretty hard to do though, so we may have to do it manually.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: cropping color bars from manuscript images

Post by snibgo »

You've given only one example which is, of course, trivial to solve. You haven't said how other examples differ, or what they have in common. So we can only guess.

For example, perhaps the dark bar with colours always occurs on the right of the manuscript, and is always the full height of the image, and the manuscript is column-wise always lighter. If so, then a solution would be (Windows BAT syntax):

Code: Select all

convert ^
  Us88XsY.jpg ^
  +write info: ^
  -scale "x1^!" ^
  -bordercolor Black -border 1 ^
  -fuzz 20%% ^
  -format "%%@" ^
  info:
This tells me the input image is 2576x2542 pixels, and the manuscript is in the first 1950 columns. The edge is a bit fuzzy, so I'll subtract 2 pixels to clean it up.

Code: Select all

convert ^
  Us88XsY.jpg ^
  -crop 1948x+0+0 ^
  out.png
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: cropping color bars from manuscript images

Post by fmw42 »

try this (unix syntax)

Code: Select all

height=`convert Us88XsY.jpg -format "%h" info:`
width=`convert Us88XsY.jpg -crop 100x1%+0+0 +repage -bordercolor black -border 10 -fuzz 35% -format "%@" info:- | cut -dx -f1`
convert Us88XsY.jpg -crop ${width}x${height}+0+0 +repage result.jpg
This assumes the top 1% on the right is nearly black and has no color in it.

EDIT: Sorry snibgo, we were posting about the same time.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: cropping color bars from manuscript images

Post by snibgo »

As we often do. And with the same method.
snibgo's IM pages: im.snibgo.com
jimgreer
Posts: 3
Joined: 2016-01-22T11:01:51-07:00
Authentication code: 1151

Re: cropping color bars from manuscript images

Post by jimgreer »

Thanks!
Post Reply