/* *************** License:************************** Oct. 3, 2008 Right to use this code in any way you want without warrenty, support or any guarentee of it working. BOOK: It w...">
Home » Source Code » image processing

image processing

2014-01-04 01:11:39
The author
Download(s): 1
Point (s): 1 
Category Category:
Image ProcessingImage Processing CPlusPlus, C-C++C++


space:nowrap;">/* *************** License:**************************
Oct. 3, 2008
Right to use this code in any way you want without warrenty, support or any guarentee of it working.

BOOK: It would be nice if you cited it:
Learning OpenCV: Computer Vision with the OpenCV Library
by Gary Bradski and Adrian Kaehler
Published by O'Reilly Media, October 3, 2008

Or: http://oreilly.com/catalog/9780596516130/
ISBN-10: 0596516134 or: ISBN-13: 978-0596516130

* The source code is on sourceforge at:
* The OpenCV wiki page (As of Oct 1, 2008 this is down for changing over servers, but should come back):
* An active user group is at:
* The minutes of weekly OpenCV development meetings are at:
************************************************** */

#include <stdio.h>
#include <cv.h>
#include <highgui.h>
#include <stdio.h>

void f(
IplImage* src,
IplImage* dst
) {
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* comp = NULL;

cvPyrSegmentation( src, dst, storage, &comp, 4, 200, 50 );
int n_comp = comp->total;

for( int i=0; i<n_comp; i++ ) {
CvConnectedComp* cc = (CvConnectedComp*) cvGetSeqElem( comp, i );
// do_something_with( cc );
cvReleaseMemStorage( &storage );

int main(int argc, char** argv)

// Create a named window with a the name of the file.
cvNamedWindow( argv[1], 1 );
// Load the image from the given file name.
IplImage* src = cvLoadImage( argv[1] );
if(!src) { printf("Couldn't seem to Open %s, sorryn",argv[1]); return -1;}
IplImage* dst = cvCreateImage( cvGetSize(src), src->depth, src->nChannels);
f( src, dst);

// Show the image in the named window
cvShowImage( argv[1], dst );

// Idle until the user hits the "Esc" key.
while( 1 ) { if( cvWaitKey( 100 ) == 27 ) break; }

//Clean up and Don 鈥 horsewhip be Piggies
cvDestroyWindow( argv[1] );
cvReleaseImage( &src );
cvReleaseImage( &dst );


Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
image2.32 kB2008-10-07|10:00
image2.54 kB2008-10-07|10:00
image2.57 kB2008-10-07|10:00
image2.88 kB2008-10-07|10:00
image0.00 B2014-01-03|10:01
Sponsored links


(Add your comment, get 0.1 Point)
Minimum:15 words, Maximum:160 words

Very well explained,and implemented project.


great tutorial even for newbiew like me

  • 1
  • Page 1
  • Total 1

image processing (5.57 kB)

Need 1 Point(s)
Your Point (s)

Your Point isn't enough.

Get 22 Point immediately by PayPal

Point will be added to your account automatically after the transaction.

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more Points


Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com


CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D