Solved

How to remove noise in the image?

Posted on 2009-05-04
13
2,108 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
  • 4
  • 4
  • 3
  • +1
13 Comments
 
LVL 47

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
 
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 47

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 47

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 47

Expert Comment

by:dbrunton
ID: 24335109
0
 
LVL 8

Accepted Solution

by:
BdLm earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now