Re: adding noise to an image



Amadeus W.M. wrote:

Thanks for the answer! I know about noise, I do computer vision for a
living. I wasn't sure how to draw it. I guess there's no way around
having e.g. a
vector<Gdk::Color> gray(256);
Glib::RefPtr<Gdk::Colormap> cmap = Gdk::Colormap::get_system(); // e.g.

for(int i=0; i<gray.size(); i++)
	gray[i].set_grey_p(i/256.0*100);

cmap->allocate_colors(gray, ... ); // do I need to allocate them?


Anyway, it's not very easy to have a pixbuf with shapes drawn on it, and
noise. You run into all sorts of unpleasant interactions, so I decided
to make a separate application for noise, after no more shapes are being
drawn.
Thanks again.


For an explanation of noise, take a look at this:
http://www.icaen.uiowa.edu/~dip/LECTURE/ImageProperties3.html#noise

Decide on a value for sigma and then use the slider to change this value. I'd have to take a look at how you draw your image to be sure on the best way to add this. Generally, you should look at adding it to your pixmap before drawing it with whichever drawing function you use.

Good luck
Paul

lol, well I bet you do know about noise then.

A thought just occurred to me. An easy way to do this would be draw the shapes by hand. Then you could just add noise at the end to your image data.

Might be a bit inefficient having two copies of the image around( the original and the noisy ). But drawing the shapes and the noise could be done failry simply.

img = get_original_img() ;

for( int y = 0 ; y < img_height ; y++ )
{
   for( int x = 0 ; x < img_width ; x++ )
   {
         if( on_shape_border( x, y )
         {
            img[ y * img_width + x ] = border_val ;
         }

         image[ y * img_width + x ] = get_noised_val( x, y )
   }
}

draw resulting image to drawing area.

Just a thought.

Cheers,
Paul



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]