Suppose an image has noise, but it is exclusively salt noise. What effect will dilation have? I am looking for a reference so I can answer this question. anyone has any idea?


1 Answer 1


To answer your 1st question, dilation will enlargen the white spots in your image over the darker spots, which may be useful if you only have tiny dark salting you would like to remove in your image.

However, you are referring to salt noise, so if the spots were also white crumbs in a dark image, then all you are doing is only making the crumbs bigger, which is what you don't want.

What I would recommend is to use either Opening or Closing, (or both) depending on your application. These are a combination of dilations and erosions so that the minor parts of the image are removed while keeping the original portions of the image intact.

For example, here is an image for a penguin (with salting): enter image description here

Notice how the image has both black and white salting.

Running both an opening and closing algorithm (OpenCV) on this penguin, we remove the black and white salts, and get a nice, smoother image without the spots:

Un-salted Penguin

Also, here is my OpenCV code that does this:

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main( )
     Mat image,dst;
     image = imread("saltnoise.png", CV_LOAD_IMAGE_GRAYSCALE);

     // Create a structuring element
     int erosion_size;
     cout << "What element size?" << '\n';
     cin >> erosion_size;

     imshow("Salted", image);

     Mat element = getStructuringElement(cv::MORPH_ELLIPSE,
            cv::Size(2 * erosion_size + 1, 2 * erosion_size + 1),
            cv::Point(erosion_size, erosion_size) );

    //Opening and Closing


     imshow("Unsalted", image);

     return 0;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.