For Programmers: Free Programming Magazines  


Home > Archive > PostScript > March 2007 > Flood-filling black image with white









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Flood-filling black image with white
Andre Majorel

2007-03-12, 10:05 pm

Is there a tool to go through a PostScript document, look at the
images and turn all large contiguous black (or dark) areas to
white ? So that it can be printed without wasting too much ink...

--
André Majorel <URL:http://www.teaser.fr/~amajorel/>
(Counterfeit: kypigyz@telemeter.com alumucam@vigilant.com)
Second rule of Usenet : I know things you don't know, you don't
know anything I don't know.
Aandi Inston

2007-03-12, 10:05 pm

Andre Majorel <cheney@halliburton.com> wrote:

>Is there a tool to go through a PostScript document, look at the
>images and turn all large contiguous black (or dark) areas to
>white ? So that it can be printed without wasting too much ink...


This could only really be done by rasterising the PostScript to
another format, then analysising the resulting bitmap. Never heard of
such a tool.
----------------------------------------
Aandi Inston
Please support usenet! Post replies and follow-ups, don't e-mail them.

Andre Majorel

2007-03-12, 10:05 pm

On 2007-03-12, Aandi Inston <quite@dial.pipex.con> wrote:
> Andre Majorel <cheney@halliburton.com> wrote:
>
>
> This could only really be done by rasterising the PostScript to
> another format, then analysising the resulting bitmap. Never heard of
> such a tool.


Couldn't you parse the PostScript source, look for image
constants, and decode and process them one by one ?

Although getting it right in the general case would require a
complete PostScript interpreter, I suspect that a program that
just looks for keywords would work on enough documents to be
useful.

--
André Majorel <URL:http://www.teaser.fr/~amajorel/>
(Counterfeit: mowin@sprawl.com ujabuf@tsunamix.info)
Second rule of Usenet : I know things you don't know, you don't
know anything I don't know.
Aandi Inston

2007-03-12, 10:05 pm

Andre Majorel <cheney@halliburton.com> wrote:

>On 2007-03-12, Aandi Inston <quite@dial.pipex.con> wrote:
>
>Couldn't you parse the PostScript source, look for image
>constants, and decode and process them one by one ?


Parsing PostScript is the same job as interpreting it: you can only
get to the image data by doing the complete job of interpreting (in
the general case). So this would be a much harder task than just
raserising everything.
>
>Although getting it right in the general case would require a
>complete PostScript interpreter, I suspect that a program that
>just looks for keywords would work on enough documents to be
>useful.


It depends on how the "set of documents" is defined. For example if
all documents are those made with one driver it may be practical. But
what is really gained?
----------------------------------------
Aandi Inston
Please support usenet! Post replies and follow-ups, don't e-mail them.

Don Lancaster

2007-03-12, 10:05 pm

Aandi Inston wrote:
> Andre Majorel <cheney@halliburton.com> wrote:
>
>
>
>
> This could only really be done by rasterising the PostScript to
> another format, then analysising the resulting bitmap. Never heard of
> such a tool.
> ----------------------------------------
> Aandi Inston
> Please support usenet! Post replies and follow-ups, don't e-mail them.
>


Trivial with the tools on our website.

But, in absence of document images, all you have to do is revise the
fill command.

But the task makes no sense whatsoever.



--
Many thanks,

Don Lancaster voice phone: (928)428-4073
Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml email: don@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com
François Robert

2007-03-12, 10:05 pm

Andre Majorel <cheney@halliburton.com> wrote in
news:slrnevama9.2qt.cheney@atc5.vermine.org:

> So that it can be printed without wasting too much ink...


If you are taking about *raster image* embedded in Postscript code,
then you can invert most of them pretty easily by tweaking the
/Decode array (for Indexed colorspace, need to tweak the palette
itself)
You can also invert the entire page with a transfer function.

You can also bracket each image rendering code (not limited to
rasters) with a setting/unsetting of a transfer function that inverts
it.
________________________________________
_______________
François Robert
Aandi Inston

2007-03-12, 10:05 pm

Andre Majorel <cheney@halliburton.com> wrote:

>Couldn't you parse the PostScript source, look for image
>constants, and decode and process them one by one ?


By the way, you really do want to just do images? Ignoring solid
blocks of colour from non-image sources?
----------------------------------------
Aandi Inston
Please support usenet! Post replies and follow-ups, don't e-mail them.

Andre Majorel

2007-03-12, 10:05 pm

On 2007-03-12, Aandi Inston <quite@dial.pipex.con> wrote:
> Andre Majorel <cheney@halliburton.com> wrote:
>
>
> By the way, you really do want to just do images? Ignoring solid
> blocks of colour from non-image sources?


That would be good to have too but I wouldn't kick a tool that
did just the images out of bed, so to speak.

--
André Majorel <URL:http://www.teaser.fr/~amajorel/>
(Counterfeit: mypif@hooligan.com wos@wing.com)
Second rule of Usenet : I know things you don't know, you don't
know anything I don't know.
hoffmann@fho-emden.de

2007-03-12, 10:05 pm


Andre Majorel schrieb:

> Is there a tool to go through a PostScript document, look at the
> images and turn all large contiguous black (or dark) areas to
> white ? So that it can be printed without wasting too much ink...
>
> --
> Andr=E9 Majorel <URL:http://www.teaser.fr/~amajorel/>
> (Counterfeit: kypigyz@telemeter.com alumucam@vigilant.com)
> Second rule of Usenet : I know things you don't know, you don't
> know anything I don't know.


Andre,

why the heck do you want to replace black by white in images ?

a) there are hardly ever large solid black areas in raster images.
b) flood-fill requires a segment boundary. Everything in a segment
is filled by a color, expanding from a starting point to such a
boundary. Raster images don't have boundaries like this.
c) just to save ink, using commercial programs, you can make
the respective image not printable. The page layout, text and
vector graphics are shown correctly, but the image is for
instance replaced by a gray rectangle.

Best regards --Gernot Hoffmann

Andre Majorel

2007-03-12, 10:05 pm

On 2007-03-12, François Robert <moc.xeta@trebor.siocnarf> wrote:
> Andre Majorel <cheney@halliburton.com> wrote in
> news:slrnevama9.2qt.cheney@atc5.vermine.org:
>
>
> If you are taking about *raster image* embedded in Postscript code,
> then you can invert most of them pretty easily by tweaking the
> /Decode array (for Indexed colorspace, need to tweak the palette
> itself)
> You can also invert the entire page with a transfer function.
>
> You can also bracket each image rendering code (not limited to
> rasters) with a setting/unsetting of a transfer function that inverts
> it.


Interesting, thanks. But not ideal for me as most of the images
also have large patches of white.

Alternatively, are there tools out there to read a PostScript
source and filter each raster image through an arbitrary program ?

It does not have to work in 100% of the cases, as long as it
works on /my/ files.

--
André Majorel <URL:http://www.teaser.fr/~amajorel/>
(Counterfeit: nuwawuboq@becker.com limoham@phenomena.com)
Second rule of Usenet : I know things you don't know, you don't
know anything I don't know.
Andre Majorel

2007-03-12, 10:05 pm

On 2007-03-12, hoffmann@fho-emden.de <hoffmann@fho-emden.de> wrote:
> Andre Majorel schrieb:
>
>
> why the heck do you want to replace black by white in images ?
>
> a) there are hardly ever large solid black areas in raster images.


If there weren't in mine, I wouldn't ask. :-)

> b) flood-fill requires a segment boundary. Everything in a segment
> is filled by a color, expanding from a starting point to such a
> boundary. Raster images don't have boundaries like this.


Raster images don't have boundaries ? We must not have grown
around the same raster images. But anyway, flood fill might not
be the right term as I don't have any particular starting point.
The goal is to re-colour all dark patches whose area is greater
than some threshold.

> c) just to save ink, using commercial programs, you can make
> the respective image not printable. The page layout, text and
> vector graphics are shown correctly, but the image is for
> instance replaced by a gray rectangle.


I should have mentioned that ; I'm only interested in libre
software.

--
André Majorel <URL:http://www.teaser.fr/~amajorel/>
(Counterfeit: suj@buried.com ypaxocuz@barycentric.com)
Second rule of Usenet : I know things you don't know, you don't
know anything I don't know.
Don Lancaster

2007-03-13, 7:09 pm

Andre Majorel wrote:

> Alternatively, are there tools out there to read a PostScript
> source and filter each raster image through an arbitrary program ?
>


Print to disk uncompressed.
Then search on "image".


--
Many thanks,

Don Lancaster voice phone: (928)428-4073
Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml email: don@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com
hoffmann@fho-emden.de

2007-03-14, 8:07 am


Fran=E7ois Robert schrieb:

> Andre Majorel <cheney@halliburton.com> wrote in
> news:slrnevama9.2qt.cheney@atc5.vermine.org:
>
>
> If you are taking about *raster image* embedded in Postscript code,
> then you can invert most of them pretty easily by tweaking the
> /Decode array (for Indexed colorspace, need to tweak the palette
> itself)
> You can also invert the entire page with a transfer function.
>
> You can also bracket each image rendering code (not limited to
> rasters) with a setting/unsetting of a transfer function that inverts
> it.
> ________________________________________
_______________
> Fran=E7ois Robert


Fran=E7ois ,

for a PostScript printer, the transfer functions can be defined
in the PPD file. Here is an example:
http://www.fho-emden.de/~hoffmann/qms6100trc.ppd

This would allow harsh modifications as wanted by the OP,
without manipulating the PS file.
One can define such a deliberately wrong printer by assigning
the modified PPD.

Best regards --Gernot Hoffmann

Fran=E7ois

Don Lancaster

2007-03-14, 10:07 pm

hoffmann@fho-emden.de wrote:
> François Robert schrieb:
>
>
>
>
> François ,
>
> for a PostScript printer, the transfer functions can be defined
> in the PPD file. Here is an example:
> http://www.fho-emden.de/~hoffmann/qms6100trc.ppd
>
> This would allow harsh modifications as wanted by the OP,
> without manipulating the PS file.
> One can define such a deliberately wrong printer by assigning
> the modified PPD.
>
> Best regards --Gernot Hoffmann
>
> François
>

Modifying the transfer function would in no manner discriminate between
a wanted line and an unwanted black fill area in a proc or an image.


--
Many thanks,

Don Lancaster voice phone: (928)428-4073
Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml email: don@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com