Solved

How to remove noise in the image?

Posted on 2009-05-04
13
2,118 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 48

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 48

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 48

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 48

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 10 Seattle Dataset Actions 5 79
Mydac connection data base issue 3 139
Delphi : could not find program, '...exe' 2 147
DBGrid or StringGrid ? 6 68
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

19 Experts available now in Live!

Get 1:1 Help Now