Page 1 of 1

Problems removing noise around text [SOLVED]

Posted: 2014-08-14T02:05:33-07:00
by thofas
Hello everyone,

I have problems reducing the noise (sparkles) around text i have placed into an image with "convert caption".
I tried a lot of statements/commands without any success.

The convert command is called with the following parmeters:

-quality 100
-pointsize 14
-size 300x200
-font /pathTo/arial.ttf
caption:"demo text"

This command is called for several images which will be merged into one single image via the composite command in the next step.

On this image (https://www.dropbox.com/s/116uqvbvlqzbb ... magick.jpg) you can see the little white sparkles I want to remove.
Can someone give the correct statement for this intention?

Or ist possible that there is any mistake generating the text so that the sparkles are not even displayed?

Thanks for your help!

Re: Problems removing noise around text

Posted: 2014-08-14T02:41:03-07:00
by snibgo
Don't save it as jpeg. Jpeg is horrible for areas of flat colour -- it mangles the colours.

Re: Problems removing noise around text

Posted: 2014-08-14T03:46:01-07:00
by thofas
this is not the generated image it's only cropped from a screenshot...the generated image is a png

Re: Problems removing noise around text

Posted: 2014-08-14T09:36:52-07:00
by fmw42
What version of IM and what platform? Post your full exact command line. We cannot see what colors are specified and don't know what else might be involved. We need to be able to exactly reproduce your command line to see if we get the same issue.

Was this speckling in the original png file before loaded in your viewer and screen captured? Perphap the display or screen capture converted to jpg and caused the speckling?

Re: Problems removing noise around text

Posted: 2014-08-14T22:41:31-07:00
by thofas
We run on a Linux based system with IM version 6.5.3.

Following the full command line:

/usr/local/im/bin/convert -quality 100 -pointsize 14 -size 400x200 -font /font/arial.ttf caption:"this is a demo text" test.png

The specklings are first shown after this step.

Re: Problems removing noise around text

Posted: 2014-08-14T22:45:06-07:00
by fmw42
Your version of IM is over 350 versions old. I would suspect it has a bug. You should upgrade IM.

It could also be an older version of PNG that is at issue.

Also your command has no color specified, so it cannot be what you used to create the image you showed earlier. Furthermore, the image would not correspond to the size you specified in your earlier command. You would have had to crop it. Also -quality 100 is not necessarily a correct quality for PNG (but would have been for saving as jpg). So did you really save the file as PNG or JPG?

So again, please provide the exact code that was used to create the image you provided.


Try this command. It works fine for me with no speckling. What does it look like for you?

Code: Select all

convert -size 400x200 -background lightblue -fill black -pointsize 14 -font arial \
-gravity center caption:"this is a demo text" -gravity center -crop 128x26+0+0 +repage test.png

Re: Problems removing noise around text

Posted: 2014-08-14T23:42:34-07:00
by thofas
The image I've posted earlier is a crop from a screenshot of the complete generated image.
I generate different single images with texts inside and composite them later to one image, from this image (the backround color is in another image) I took the screenshot.
...but the spacklings are visible before the composite command is called.

But what I want to do ist to generate the texts on transparent PNGs, maybe this was not clear in my last posts, sorry for that.

I also missed to say that I call this command after the last to remove the white background:

Code: Select all

/usr/local/im/bin/convert test.png  -transparent white test.png
An Update to another IM version won't pe possible because of hoster restrictions.

The command you've posted works fine on my system, too. So the problem muste be somewhere else...

EDIT:

Here is the background image where the different PNGs within the texts will beplaced on:

https://www.dropbox.com/s/52d192oigf7pr ... ground.png

Re: Problems removing noise around text

Posted: 2014-08-15T00:30:11-07:00
by snibgo
The trick is to show us the exact commands that make the speckling. If the commands need input images files, then also show those.

Re: Problems removing noise around text

Posted: 2014-08-15T00:49:37-07:00
by thofas
Here are all commands that are called:

First command (generate PNG with text, for every single text)

Code: Select all

/usr/local/im/bin/convert -quality 100 -pointsize 14 -size 400x200 -font /font/arial.ttf caption:"this is a demo text" test.png
Second command (remove white background from PNG, for every single text)

Code: Select all

/usr/local/im/bin/convert test.png  -transparent white test.png
Third command (compose them together with background image)

Code: Select all

/usr/local/im/bin/convert background_image.png \
	text_image_1.png -geometry +165+10 -composite \
	text_image_2.png -geometry +165+40 -composite \
	text_image_3.png -geometry +635+60 -composite \
composed_image_with_texts.png

Re: Problems removing noise around text

Posted: 2014-08-15T01:36:22-07:00
by snibgo
You haven't provided a complete set of commands that someone else can run.

Assuming the background image is the one you supplied above, I ran this...

Code: Select all

convert -quality 100 -pointsize 14 -size 400x200 caption:"this is a demo text" test.png

convert test.png  -transparent white test.png

convert background.png test.png -geometry +165+10 -composite composed_image_with_texts.png
... on IM v6.8.9-5 on Windows 8.1. There is no speckling. Here is the output:
Image
If your result to these commands has speckles, please post it.

Re: Problems removing noise around text

Posted: 2014-08-15T02:05:09-07:00
by thofas
I've set the text a littler lower into the blue section, so the result becomes clearer.

There are speckles again as you can see in my output:

https://www.dropbox.com/s/jjo1p9ruip51o ... _texts.png

Could it be that there are any problems with the fonts? It looks like your default font ist Arial?
In my case IM uses a Times New Roman as default. But when I set the -font paramter to use the Verdana font the output looks similar.

Output with Verdana font:

https://www.dropbox.com/s/cbyn82zgj8nwh ... erdana.png

Re: Problems removing noise around text

Posted: 2014-08-15T03:13:42-07:00
by snibgo
Ahh, now I understand.

When text etc is written, the edges are antialiased. So pixels at the edge are light gray, dark gray and so on. You make white transparent, but leave the gray pixels at the edge.

When you create the text, use "+antialias" to turn it off. Better, use "-background none" to make the background transparent. Then you don't need to turn white into transparent.

Re: Problems removing noise around text

Posted: 2014-08-15T03:58:08-07:00
by thofas
yeah, nice to see that we come closer to the problem! ;-)

but we're still not quite there...

1. when I use "+antialias" the text will be reduced very hard, as you can see in the picture below.
2. the command

Code: Select all

convert test.png  -background none test.png
doesn't turn my background into transparent... :-/

https://www.dropbox.com/s/vwgyr4np7hnjclt/test.png

Re: Problems removing noise around text

Posted: 2014-08-15T05:05:22-07:00
by snibgo
Use "-background none" when writing the caption:

Code: Select all

convert -background None -quality 100 -pointsize 14 -size 400x200 caption:"this is a demo text" test.png

convert background.png test.png -geometry +165+50 -composite composed_image_with_texts.png

Re: Problems removing noise around text

Posted: 2014-08-15T06:10:04-07:00
by thofas
Yeah, that's it!!! Thank you!
That's crazy I used the "-background" parameter in the past but apparently in the wrong place... :)