Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6572697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:02:21+00:00 2026-05-25T15:02:21+00:00

I am working on a black&white image just like the first one from the

  • 0

I am working on a black&white image just like the first one from the link :
http://imageshack.us/g/33/firstwm.png/
It has a lot of “noise” so I applied a Median filter over it to smooth it, thus getting the second picture.

cvSmooth(TempImage, TempImage, CV_MEDIAN, 5, 0);

After this i get the contours and draw them on another image like the 3rd picture from the link.
My problem is that the contours are still a little pixelated(edgy). Is there a way to smooth the B&W image even more so to obtain better contours? Or maybe do something with the contours.
I have also tried Dilate and Erode with different kernels but the problem remains the same.
Thank you for anything that helps.

EDIT:
Also tried:

cvSmooth(TempImage, TempImage, CV_GAUSSIAN, 9, 9, 3);
cvThreshold(TempImage, TempImage, 127, 255, CV_THRESH_BINARY);

Same results as median filter, ok, but still leaves some pixelated contours.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:02:22+00:00Added an answer on May 25, 2026 at 3:02 pm

    enter image description here

    If this is the smoothing result you’re after, it can be obtained by doing a Gaussian blur, followed by a thresholding. I.e. using cvSmooth with CV_GAUSSIAN as the paramater. Followed by a cvThreshold.

    If you want a smoother transition than thresholding (like this), you can get that with adjusting levels (remapping the color range so that you preserve some of the edge transition).

    update To explain how to get the smooth (anti-aliased) edge on the thresholding, consider what the thresholding does. It basically processes each pixel in the image, one at a time. If the pixel value is lower than the threshold, it is set to black (0), if not it is set to white (255).

    The threshold operator is thus very simple, however, any other general mapping function can be used. Basically it’s a function f(i), where i is the intensity pixel value (ranged 0-255) and f(i) is the mapped value. For threshold this function is simple

     f(i) = {   0, for i  < threshold
              255, for i >= threshold
    

    What you have is a smoothed image (by cvSmooth using a Gaussian kernel, which gives you the “smoothest” smoothing, if that makes sense). Thus you have a soft transition of values on the edges, ranging from 0 to 255. What you want to do is make this transition much smaller, so that you get a good edge. If you go ballistic on it, you go directly from 0 to 255, which is the same as the binary thresholding you’ve already done.

    Now, consider a function that maps, maybe a range of 4 intensity values (127 +- 4) to the full range of 0-255. I.e.

             f(i) = {   0,  for i  < 123
                      255,  for i >= 131
           linear mapping,  for 123 <= i < 131
    

    And you get the desired output. I’ll take a quick look and see if it is implemented in openCV already. Shouldn’t be too hard to code it yourself though.

    update 2
    The contour version would be something like this:

                  f(i) = { 255,  for        i < 122
       linear mapping (255->0),  for 122 <= i < 126
                             0,  for 126 <= i < 127
       linear mapping (0->255),  for 127 <= i < 131
                           255,  for 131 <= i
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to extract (not recognize!) characters from a black & white image, so
What's currently working in my code: I select a JPG or PNG from the
I'm working on a block module and would like to perform ajax operations on
I'm currently working on the back-end of ACM-like public programming contest system. In such
I'm working with a device that sends back an image, and when I request
I'm working on an app to block GtalkService. I want just use iptables for
I wrote one script which gets an image url through JSONP, and then I
I'm currently working on a heading in joomla with background formed from 5 parts
I'm attemting to load an image that I exported from flash CS3 it's a
I have an application that requires some work on image filters, so I just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.