Page 1 of 2

Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-04-30T18:12:58-07:00
by XnTriq
Hello ImageMagick. I have a movie poster which I scanned in & stitched to have a digital version. This is the 1999 Dreamworks feature film "Galaxy Quest" if anyone cares (and not incidentally, one of the 5 best comedies ever made imho).

Below is a slice from the poster, and it is this portion — the credits — I am hoping IM can help me clean up. As with most feature films today, Dreamworks used a severely-condensed font to fit in all the credits, so here are my two goals:
  1. Pull up the contrast
  2. Render the text in grayscale without appreciably damaging the pattern and/or color surrounding the text.
I tried adding noise but to be honest that's a crude way to approach this design. I'm not necessarily averse to adding noise, but for this first step I want to preserve the poster's original concept. Thank you for any help.

EDIT
I'm not certain why the graphic won't display, but here is the link.

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-04-30T18:56:33-07:00
by fmw42
Is it legal to remove the credits from a movie without permission?

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-04-30T19:18:55-07:00
by XnTriq
Exactly the opposite: I'm not removing the credits, I'm trying to make them more legible. What about the following quote from my post is ambiguous:
XnTriq wrote: 2018-04-30T18:12:58-07:00... I want to preserve the poster's original concept.

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-04-30T19:33:13-07:00
by snibgo
The OP's aim seems to be to make the text more readable, rather than remove it. Re-publishing an amended movie poster might have copyright implications. I don't know.

The condensing is horizontal, so a resize easily fixes that:

Code: Select all

%IM%convert im-rev-999999.png -resize 200x100% out.png
If you don't want to stretch, but simply increase contrast to increase legibility, a sharpening will do that, eg:

Code: Select all

%IM%convert im-rev-999999.png -unsharp 0x3 out.png

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-01T13:53:12-07:00
by XnTriq
snibgo wrote: 2018-04-30T19:33:13-07:00 The OP's aim seems to be to make the text more readable, rather than remove it. Re-publishing an amended movie poster might have copyright implications. I don't know.
Thank you snibo. For the record, this graphic is for my digital "Film Scrapbook" where I keep notes, links, year released, cast notes etc. on my personal hard drive. I invest a great deal of time cleaning up these poster scans and I don't offer the fruits of my labor cheaply, let alone free. So for the record:
  1. Do I look like I want to be sued by Dreamworks? :lol: tsk tsk.
  2. The scanned versions of all of my film/TV posters are stored on my computer's hard drive. I don't share them with anybody, but if you want to pay me for the time I invest in producing their digital versions you're looking at $X,XXX-and-up. At that point the studio will require a change of venue because I will have moved to ¹Tahiti.
  3. I own the poster and it will never be publicly displayed outside of our house as long as I own it.
  4. If I decide at some point to sell this or any other physical poster from my collection — for example on Ebay — the only representational auction image displayed in my listing will be either the stock image Ebay uses for everyone else's same poster listing -or- (what is more likely) a picture of the poster lying flat on our floor carpeting, taken using a cellphone.
  5. The resulting Vanishing Point of View would so completely Skew the image as to render it the deliberately crude, small thumbnail I'm willing to release into the public domain because you ain't getting my hi-res one! (see ¹Tahiti)

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-01T14:11:47-07:00
by XnTriq
snibgo wrote: 2018-04-30T19:33:13-07:00 The condensing is horizontal, so a resize easily fixes that:

Code: Select all

%IM%convert im-rev-999999.png -resize 200x100% out.png
If you don't want to stretch, but simply increase contrast to increase legibility, a sharpening will do that, eg:

Code: Select all

%IM%convert im-rev-999999.png -unsharp 0x3 out.png
This is very interesting snibgo! I have graphics editors (not Photoshop, too hard) and any of them can stretch horizontally. Likewise, I have programs that can sharpen an image.

What I don't have is the means to replace/change colors inside of the of the text in such a manner that the colors surrounding the text are not affected. Is that what your second operation does?

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-02T05:08:21-07:00
by snibgo
Any sharpening process increases local contrast. (It increases high-frequency data.) At an edge, eg the edge of light lettering against a dark background, light pixels will become lighter and dark pixels will become darker. With a suitable sigma such as the one I showed, the effect carries across the width of each letter stroke.

"-unsharp" uses an unshark-mask, ie a blurred mask. It changes tones but not colours. Alternative methods change colours and not tones, or both colours and tones.

Another option is to make a mask using the colour of the lettering, then to change the colour or lightness of pixels defined by that mask. That is more complex.

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-02T07:05:54-07:00
by XnTriq
snibgo wrote: 2018-05-02T05:08:21-07:00 Any sharpening process increases local contrast. (It increases high-frequency data.) At an edge, eg the edge of light lettering against a dark background, light pixels will become lighter and dark pixels will become darker. With a suitable sigma such as the one I showed, the effect carries across the width of each letter stroke.

"-unsharp" uses an unshark-mask, ie a blurred mask. It changes tones but not colours. Alternative methods change colours and not tones, or both colours and tones.

Another option is to make a mask using the colour of the lettering, then to change the colour or lightness of pixels defined by that mask. That is more complex.
Yes snibgo, I understand sharpening and contrast, and can do that now with my graphics editors, but it is like taking a hammer to swat a fly: crude, rough. If the inside-the-lettering-color-range + surrounding-image/color-unaffected script is too complex I can go back to doing it manually. I guess I thought if any tool could do this with precision it would be ImageMagick.

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-02T07:26:50-07:00
by snibgo
That image is difficult because of the variety of colours within the text strokes. There are no solid colours. Of course, we can easily change any selection to whatever we want, eg:

Code: Select all

magick im-rev-999999.png -fuzz 5% -fill White -opaque #abc x.png
... but the result merely turns some of the pixels in the lettering white. In my opinion, it doesn't improve legibility. In fact, it makes legibility worse.

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-02T12:19:27-07:00
by XnTriq
It's so frustrating snigbo! I can't ask you to do the impossible, so I'm sitting here hacking away at it manually. I expanded the width to 5400px which was helpful to the extent I don't have to go blind while I'm masking. :shock: I've tried posterizing. I've tried starving its color profile. Worse yet, I'm facing an endless supply of poster clean-up projects like this because all the studios use these crammed fonts on their posters.

I've never compiled an ImageMagick script before, ever. I don't mind spending a week or two fashioning my first script and then reporting in here to tweak & fine tune the code, but as you say, this is a complex project.

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-02T13:53:12-07:00
by snibgo
For the general case, if you have many posters to process, algorithms exist for detecting text. They detect edges that are roughly parallel to each other, within a certain range of distances. The results are readable by OCR. I don't know if those algorithms have been implemented in generally-available software.

For movie posters, that's probably overkill, because finding the text isn't difficult: it's a rectangle near the bottom that contains high-spatial-frequency data. Crop to that rectangle, and whack up the contrast. Assuming light letters on dark background, we make 50% of pixels black and 10% white:

Code: Select all

magick im-rev-999999.png -crop 1684x235+84+72 -channel RGB -contrast-stretch 50,10% +channel x.png

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-03T13:26:31-07:00
by XnTriq
snibgo wrote: 2018-05-02T13:53:12-07:00 For the general case, if you have many posters to process, algorithms exist for detecting text. They detect edges that are roughly parallel to each other, within a certain range of distances. The results are readable by OCR. I don't know if those algorithms have been implemented in generally-available software.
snigbo your advice is as deep as it is prescient. I'm not joking when I say you are really really really smart! I'm not only taking a screenshot of your comments, I'm ripping the entire thread for a permanent reference! You explore alternatives I just never even thought of. Wow. Thank you.
snibgo wrote: 2018-05-02T13:53:12-07:00 (cont'd) For movie posters, that's probably overkill, because finding the text isn't difficult: it's a rectangle near the bottom that contains high-spatial-frequency data. Crop to that rectangle, and whack up the contrast. Assuming light letters on dark background, we make 50% of pixels black and 10% white:

Code: Select all

magick im-rev-999999.png -crop 1684x235+84+72 -channel RGB -contrast-stretch 50,10% +channel x.png
I referenced my flatbed scanner in my lead post, but it just so happens I also have OmniPage 15 (that's a commercial OCR program for anyone just learning about some of these terms). I never thought of tackling my little poster projects that way. It's a curious approach. I don't doubt OmniPage can recognize the text, but what you're asking is (if I'm reading your comments correctly) would it produce the font.

For intellectual property & trademark reasons OmniPage can produce a digital-file/clipboard-copy of plain text -or- as close a typeset replica of the original font if that font was already installed on your computer.

If your project were for example, the lengthy chapter of a book with title headers and footnotes, this might make sense. But a roll of cast members, titles, studio, runtime, release year, address data etc. amounting to the equivalent of a large paragraph? Follow the thought to its conclusion: You might as well just type it.

Yes, I have attempted even that, to my shame! :lol: (it could be worse; my hobby could be collecting Model T Fords!).

So snigbo I'd like to return to the most recent of your scripts. Please note:
  1. I've changed the name of file we're operating on from im-rev-999999.png to GQ-99.png
  2. The batch file should be named GQ-99.bat
  3. Both files have been copied directly into my ImageMagick program folder
The environment is:
Z:\WINDOWS\system32\cmd.exe
Z:\[PROGRAMS] XP\IMAGEMAGICK\GQ-99.png
Z:\[PROGRAMS] XP\IMAGEMAGICK\GQ-99.bat
.


The batch file reads:
Z:\[PROGRAMS] XP\IMAGEMAGICK\convert magick GQ-99.png -crop 1684x235+84+72 -channel RGB -contrast-stretch 50,10% +channel x.png
and the error I get is

Code: Select all

Windows cannot find 'Z:\[PROGRAMS XP]\IMAGEMAGICK\convert magick GQ-99.png -crop 1684x235+84+72 -channel RGB -contrast-stretch 50,10% +channel x.png'. Make sure you typed the name correctly, and then try again. (SNIP)
whether I manually open a command prompt -or- perform a "Run As" Administrator on GQ-99.bat

I've Googled for a Beginner's Tutorial on ImageMagick but the content on the imagemagick-org site has been removed, and the one PDF I was able to find is focused on the "Magick++ C++ graphics library". If I haven't lost you yet snigbo I would very much appreciate active links to Beginner's guides and tutorials. Thank you everyone. I apologize for the length but I am a Writer (no, we'd never guess!)

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-03T13:41:13-07:00
by XnTriq
Okay, just two more things:
Collecting movie posters is my hobby. I don't batch process eg. a stack of movie posters, I might do six a year. My point was that those six posters — and virtually every poster I want to back up digitally, in perpetuity — will all use similar hyper-condensed fonts for their credits.
This is my last poster project before I zero-fill my drives and install Windows 7 64-Bit. No one agrees more than me that XP needs to go.

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-03T14:29:51-07:00
by snibgo
XnTriq wrote:I might do six a year.
Oh, I was thinking you had hundred or thousands. I'd re-type them. Much easier. 30 minutes per poster, 3 hours per year.
XnTriq wrote:Z:\[PROGRAMS] XP\IMAGEMAGICK\convert magick GQ-99.png -crop 1684x235+84+72 -channel RGB -contrast-stretch 50,10% +channel x.png
If you have spaces in the program name, or any other filename including its directory, it needs to be quoted. Normally in Windows, use double quotes, like this:

Code: Select all

"Z:\[PROGRAMS] XP\IMAGEMAGICK\convert"
"magick" is not a keyword recognised by the "convert" program. Remove it.

In a BAT file, percent sign % has a special meaning to Windows, but you don't want that meaning, so escape it with another %. So we get:

Code: Select all

"Z:\[PROGRAMS] XP\IMAGEMAGICK\convert" GQ-99.png -crop 1684x235+84+72 -channel RGB -contrast-stretch 50,10%% +channel x.png
XnTriq wrote:... I would very much appreciate active links to Beginner's guides and tutorials.
Some links:
http://www.imagemagick.org/Usage/basics/
http://www.imagemagick.org/Usage/
http://www.imagemagick.org/Usage/reference.html

Sadly, these refer to v6 so are now out-of-date. But better than nothing.

Re: Suggestions for cleaning severely-condensed text appearing in a graphic?

Posted: 2018-05-03T15:18:52-07:00
by fmw42
Those links probably still work for the most part, if you just replace magick for convert. Or make a symbolic link between the two so that convert is really just magick.