Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to remove noise in the image?

Posted on 2009-05-04
13
Medium Priority
?
2,257 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 50

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 50

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 50

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

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Integration Management Part 2
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses
Course of the Month14 days, 19 hours left to enroll

577 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