Page 1 of 1

How to reduce noisy pixels around rounded corners?

Posted: 2013-11-19T02:38:34-07:00
by laurens_at_hol
Hi,

I use following commandline options to create rounded corners on an input photo. The rounded image is then placed on a white background.
Problem now is that there is a little bit of noise visible on the outside of the rounded corners. A few colored pixels near the rounded corners are visible on the white background.
Somehow in the composing process the pixels outside the corners are added. How can this be prevented? Can the rounded corners be made without the noisy pixels around them?

Code: Select all

convert rose: -define jpeg:size=827x827 -density 150 +profile 8bim -thumbnail 827x827 -format "roundrectangle 0,0 %[fx:w-1],%[fx:h-1] 20,20" -write info:tmp.mvg \( +clone -alpha transparent -background none -fill '#FFFFFF' -stroke none -strokewidth 0 -draw @tmp.mvg \) -compose DstIn -composite -gravity center -background '#FFFFFF' -compose Over -extent 1063x1063 rounded_rose.jpg

Re: How to reduce noisy pixels around rounded corners?

Posted: 2013-11-19T05:54:00-07:00
by snibgo
Adjusting your command for Windows 7, IM 6.8.7-0, I get no noisy pixels.

Can you post an output image? Put in somewheree like dropbox.com and paste the URL here.

Re: How to reduce noisy pixels around rounded corners?

Posted: 2013-11-19T06:47:02-07:00
by laurens_at_hol
Here I zoomed in 500% on a corner of the rose image with rounded corners:
http://screencast.com/t/WD0fCa6JGn
I used some red arrows to point out some of the noise pixels.

I also tested now with png output instead of jpg I was using earlier.
http://screencast.com/t/WxSNTd8jnl
The png looks clean. No visible noise around the corners.

The output filesize is much bigger though and the performance with png is more time and memory consuming.
So I would love to hear some other optimizations!

Re: How to reduce noisy pixels around rounded corners?

Posted: 2013-11-19T07:37:48-07:00
by snibgo
Okay. With my conversion I can't see any bad pixels there, but using Gimp's eyedropper I can see that some pixels there are not exactly white -- for example they are rgb(249,248,254).

Jpeg is lossy which means it will in general change pixel values. This is most noticeable in areas of constant colour. The effect can be reduced by using a higher "-quality" setting. For example if I put "-quality 100" before the output filename the worst pixel is rgb(255,255,253).

The only way to guarantee that white stays white is by not compressing, or use only lossless compression. Png compression is lossless, and most "-compress" options for tiff are also lossless.

Re: How to reduce noisy pixels around rounded corners?

Posted: 2013-11-19T11:36:55-07:00
by glennrp
snibgo wrote:Okay. With my conversion I can't see any bad pixels there, but using Gimp's eyedropper I can see that some pixels there are not exactly white.
I converted the image using -gamma .02 to make the artifacts visible. The JPEG quality is already pretty high (92) when using IM-6.8.7-5; perhaps the reporter was
using an older version that uses quality 75 by default.

Re: How to reduce noisy pixels around rounded corners?

Posted: 2013-12-03T07:58:47-07:00
by laurens_at_hol
Ok, so I'm using png output now. There are no noise pixels added around the corners, but now I have the problem of aliasing.
The corners are not as smooth as I would like them to have (visible in the screenshot posted earlier).
I tested a bit with -blur but I was not getting smooth (anti-aliased) corners.

Could someone help me modify my convert command so that the corners are smooth, without adding other visible pixels around the corner areas?
Thanks!

Re: How to reduce noisy pixels around rounded corners?

Posted: 2013-12-03T08:53:49-07:00
by snibgo
I think IM's anti-aliasing is accurate. To see it without, use "+antialias". Yeah, using "+" to turn is off seems weird, but that's the way it works.

If you don't like it with or without antialasing, can you create what you want in Gimp or similar? If you show us that, maybe we can do it with IM.