?
Solved

How to remove noise in the image?

Posted on 2009-05-04
13
Medium Priority
?
2,184 Views
Last Modified: 2012-05-06
Hi,

  I want  to reduce noise in the image. I tried by using  some of image smoothing techniques like median,gaussian. when I apply these filters noise is reducing But  quality of the image is going. How can I reduce noise, without loosing quality.

0
Comment
Question by:inampudi1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +1
13 Comments
 
LVL 49

Expert Comment

by:dbrunton
ID: 24294546
Expect to lose quality when you alter an image.

Try using your filters with very mild settings and see what they do.  The milder the better.  The more aggressive or high the settings are the more you will lose in an image.  If it's in a particular error you may be able to cut the affected area out and apply the filters there and then paste the result back.

One other possible trick is to apply the filter and then sharpen straight away.  This may or may not work and depends on your image.
0
 

Author Comment

by:inampudi1
ID: 24294991
Hi dbrunton,

 Thank u for reply. I will try for sharpening after smothing.
0
 
LVL 12

Expert Comment

by:Hypo
ID: 24302566
Hi, I'm not sure if this algorithm would produce any good results, but I think it could at least do some difference to just aplying a gauss filter, and I would give it a try myself:

1: Extract all the borders in the image by using vertical- and horizontal- derivative filters, store the results in a temporary image map.

2: Apply a gaussian filter to the original image, but for each pixel, you create a new gaussian filter that is more or less sharpen, depending on the corresponding value in your temporary image map.

The theory behind it is that you recognize the resolution of an image by the sharpness of the edges in the image; e.g. if you blur an edge, then you would feel that that the image looses quality, but if you blur an area with no edges, then it wouldn't affect your experience of the image as much. So what you do is that you extract all the edges of the image, and then, the more a pixel is not considered to be part of an edge, the more you blur it, and vice versa.

I haven't tested it myself yet, but I think that with some tweaking, this algorithm would result in the filters smothening areas in the image (removing noise), but not smoothing the edges of the image (not loose as much quality).

regards
Hypo
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:BdLm
ID: 24302909
can you post sample images for testing ?
0
 

Author Comment

by:inampudi1
ID: 24311471
Hi,

   Please see the test image.


leena.bmp
0
 
LVL 49

Expert Comment

by:dbrunton
ID: 24311538
Median filter works OK in Irfanview and PaintShop Pro.  But can't be aggressive.

So if this programming you are going to have to be very mild with the filter there.
0
 

Author Comment

by:inampudi1
ID: 24315764
Hi dbrunton,

   I am working on VC++, I used median filter but after sharpening image also quality is missing. Please see the software in the link,

http://www.neatimage.com/download.html

  Quality is coming very fine. He is using luminance and crominance channel. please tell me how to to get like this quality.
0
 
LVL 8

Expert Comment

by:BdLm
ID: 24316107
uses the test image with an 5x5 median filter only 1 time execution

lenoise-image-meadian-file.bmp
0
 
LVL 12

Expert Comment

by:Hypo
ID: 24317887
I had to try out the idea of removing noise using information about the edges in an image, and I think it looks ok... the algorithm works as I described above; and this is the results I got after some parameter tweaking...

regards
Hypo
RemoveNoiseFilter.PNG
0
 
LVL 49

Expert Comment

by:dbrunton
ID: 24318266
Try sharpening your Normal Gaussian blur.  Might give slightly better.



And try a 3 x 3 median filter instead of the 5 x 5.
0
 

Author Comment

by:inampudi1
ID: 24335054
Hi,

Please can u give me c++ or delphi code for MEDIAN filter.
0
 
LVL 8

Accepted Solution

by:
BdLm earned 1500 total points
ID: 24335809
will you use a pascal solution ? code is not error free, we must debug first ...

{***********************************
 *  copy the image data to a Array of integer
 *
 ***********************************}
 
procedure ScanRasterValues (aBmp : TBitmap; xstart, ystart, xsteps, ysteps : Integer; var RvalueArray, GValueArray, BValueArray : TImageFilter);
var   ByteLine  : Pbytearray;
      i, j      : integer;
begin
 
 
 
   for j := ystart to ystart + ysteps  do
         begin
 
         ByteLine := aBmp.ScanLine[j];
 
         for  i:= xstart to xstart + xsteps  do
 
                begin
 
                   BvalueArray [i-xstart, j-ystart] := ByteLine[3*i];
                   GvalueArray [i-xstart, j-ystart] := ByteLine[3*i +1];
                   RvalueArray [i-xstart, j-ystart] := ByteLine[3*i +2];
 
 
                end;
 
         end;
 
end;
 
 
 
function FilterResult (aFilter, bFilter : TImageFilter) : word;
var  i,j   :  Integer;
     n,m     :  Integer;
 
begin
     n := length( aFilter );
     m:= n;
 
 
     for i := 1 to n do
       for j := 1 to m do
          result := aFilter[i][j] * bfilter[i,j];
end;
 
{******************************************************************************
 *      Input:
 *          bmp1, bm2 : TBitMap
 *          ImageFilter  : Image Filter array , size   FilterSize x  FilterSize
 *          assume filter size is always even !!  1,3,5, ...
 *
 *    OutPut:
 *
 *
 *
 *******************************************************************************}
 
procedure ReduceNoise_AnyFilter (bmp1, bmp2 : TBitMap; aImageFilter : TImageFilter );
 
var  P1                 :    pbytearray;  //  from Image 1
     FilterSize         :    Integer;     //  3,5,7
     FilterSize2        :    Integer;     //  2,3,4
     i,j,jj             :    Integer;
     RvalueArray        :    TImageFilter;    // Red Color Values
     GvalueArray        :    TImageFilter;    // Green Color Values
     BvalueArray        :    TImageFilter;    // Blue Color Values
 
begin
     //  the filter size
     FilterSize := length(aImageFilter);
 
     FilterSize2 := round((FilterSize-1)/2 +1);
 
      //  adjust dyn. arrays
 
     setlength ( RvalueArray, Filtersize, Filtersize );
 
     setlength ( GvalueArray, Filtersize, Filtersize );
 
     setlength ( BvalueArray, Filtersize, Filtersize );
 
 
     //  Loop through all Pixels
     for j := FilterSize2 to bmp1.Height - (FilterSize2 +1) do
         begin
 
             p1 := bmp1.ScanLine[j];
 
 
             for i := FilterSize2 to bmp1.Width - (FilterSize2+1)  do
 
               begin
 
                ScanRasterValues (bmp2, i-FilterSize2, j-FilterSize2, FilterSize, FilterSize,RvalueArray, GValueArray, BValueArray );
 
 
 
                p1[3 * i ]     :=  FilterResult ( aImageFilter,BvalueArray ) ;     //  Bvalue
                p1[3 * i + 1 ] :=  FilterResult ( aImageFilter,GvalueArray ) ;     //  Gvalue
                p1[3 * i + 2 ] :=  FilterResult ( aImageFilter,RvalueArray ) ;     //  Rvalue
 
 
               end; // i := ...
 
 
 
 
         end;  //  j:= ..
end;

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question