question about how to reduce noise in image

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Locked
saeed_saba
Posts: 4
Joined: 2014-10-04T09:29:33-07:00
Authentication code: 6789

question about how to reduce noise in image

Post by saeed_saba »

Dear friends
i need some help and maybe idea about my job.
in fact i want to do these:
1- doing edge detection on grayscale images
2-export just detected edges
3-save it in *.png format
now i have a problem. you can see it in picture that i linked it.
pic 1 is base , pic 2 is edge detected image , and pic 3 is png format. but ther is a problem in pic3. in fact after this line (c# code).

btmimg.MakeTransparent(Color.Empty);
Image img = (Image)btmimg;
img.Save("1" + ".Png", ImageFormat.Png);

i see noises around the detected edges .
so anybody have any idea about this ? how can i reduce these noises ?
is there other way that export detected edges and make new image?
Image link:
http://www.imageupload.co.uk/images/201 ... ed_-_1.jpg
please help me
thanks, Saba

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: question about how to reduce noise in image

Post by snibgo »

PNG formats are loss-less, and do not introduce noise beyond rounding differences, eg when converting from floating point to integer. The input image may already have noise which is "enhanced" (made worse) by edge detection.

Can you put up an original input image?
snibgo's IM pages: im.snibgo.com

saeed_saba
Posts: 4
Joined: 2014-10-04T09:29:33-07:00
Authentication code: 6789

question about how to reduce noise in image

Post by saeed_saba »

the first link is original input image :
http://www.imageupload.co.uk/images/2014/10/05/1.jpg
and second one is edge detected image
http://www.imageupload.co.uk/images/201 ... 2CtzlM.jpg

Thanks
saba

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: question about how to reduce noise in image

Post by snibgo »

The input is 8-bit JPG, which uses lossy compression so contains noise. In this image, the dark areas are very noisy. We can remove this noise with an initial "-level 10%,100%".

I then use a Sobel edge-detector, followed by another "-level 10%,100%" to remove low-amplitude noise.

This shows some detail in both soft-tissue and bone. Adjust the parameters to vary the noise-reduction, depending on the required use. A final "-auto-gamma" helps visibility, or a different gamma could be used.

Removing more noise would also remove more detail.

Windows BAT syntax.

Code: Select all

convert ^
  skull.jpg ^
  -alpha off ^
  -level 10%%,100%% ^
  -define convolve:scale="50%%^!" -bias 50%% ^
  ( -clone 0 -morphology Convolve Sobel:0 ) ^
  ( -clone 0 -morphology Convolve Sobel:90 ) ^
  -delete 0 -solarize 50%% -level 50,0%% ^
  +level 0,70.7%% ^
  -evaluate Pow 2 ^
  -compose plus -composite  ^
  -evaluate Pow 0.5 ^
  -separate -evaluate-sequence Max ^
  -auto-level ^
  -level 10%%,100%% ^
  -depth 16 ^
  -write skull_sm2.jpg ^
  -auto-gamma ^
  skull_sm3.jpg
Image
Image
snibgo's IM pages: im.snibgo.com

saeed_saba
Posts: 4
Joined: 2014-10-04T09:29:33-07:00
Authentication code: 6789

Re: question about how to reduce noise in image

Post by saeed_saba »

Thanks for your attention
What is your opinion about another solution?
do you have any solution for me ? or not , is my solution best ?

Thanks
Saba

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

Re: question about how to reduce noise in image

Post by fmw42 »

Don't create your images in JPG, since it is lossy. If you must start with a JPG, then do not save the edge results as JPG. Go directly to PNG.

Also please always provide your IM version and platform. Perhaps you have an old version of IM or an old version of the jpg and png delegate libraries that need updating.

The works fine for me in IM 6.8.9.8 Q16 Mac OSX

Code: Select all

convert 1.jpg -auto-level -define convolve:scale='!' \
-define morphology:compose=Lighten \
-morphology Convolve 'Sobel:>' -contrast-stretch 0x1% 1_sobel.png
You can adjust the white point in the contrast-stretch to bring out more detail.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: question about how to reduce noise in image

Post by snibgo »

saeed_saba wrote:What is your opinion about another solution?
Get a better input than 8-bit JPEG. This is a medical image, so a better image (with less noise) should be available.

Other solutions are possible. What is the output for? It might be to identify bone fractures. Or voids in soft tissue. Or to make a pretty picture. If you only want to identify major edges, then more noise can be removed.

Many other techniques can be used for finding edges. See http://www.imagemagick.org/Usage/convolve/#edgedet and my "Details, details" page: http://im.snibgo.com/detail.htm
snibgo's IM pages: im.snibgo.com

saeed_saba
Posts: 4
Joined: 2014-10-04T09:29:33-07:00
Authentication code: 6789

question about how to reduce noise in image

Post by saeed_saba »

Thanks
What is the output for?
the out put is combination of two image (image3 on image1). almost the formats file is not important (only important things is that combine two image without noise).
It might be to identify bone fractures
identify bone will be enough .

Thanks
saba

Locked