Wednesday 21 March 2012

UGG Sale UKOne canadjust the parameters of the morphological examples

One canadjust the parameters of the morphological examples ,use custom kernel function : IplConvKernel * cvCreateStructuringElementEx ( int cols ,UGG Sale UK,int rows ,int anchor_x ,int anchor_y ,int shape ,int * value = NULL ) ;function parameters cols ,rows identifies the structure size of the rectangle .
Anchor_x ,Cheap Coach Bags,anchor_y identified a closed rectangular inner reference point of the horizontal and vertical coordinates .Shape is a custom kernel shape ,Nike Air Max,specific for the 1.CV_SHAPE_RECT core is rectangular 2.
CV_SHAPE_CROSS core is cross shaped spoon 3.CV_SHAPE_ELLIPSE nucleus is oval 4.CV_SHAPE_CUSTOM nuclear is user defined its release function for void cvReleaseStructuringElement ( IplConvKernel * element ) ;examples of code as follows :# include < ;cv.
h> ;include < highgui.h> ;# # ;include < ;stdlib.h> ;# include < ;stdio.h> ;IplImage * SRC = 0 ;IplImage * DST = 0 ;IplConvKernel * element = 0 ;int element_shape = CV_SHAPE_RECT ;/ / the address of variable which receives trackbar position update int max_iters = 10 ;int open_close_pos = 0 ;int erode_dilate_pos = 0 ;/ / callback function for open / close trackbarvoid OpenClose ( int POS ) {int n = open_close_pos max_iters ;int an = n > ;0 ?N :- N ;element = cvCreateStructuringElementEx ( an * 2+1 ,an * 2+1 ,an ,an ,element_shape ,if ( 0 ) ;n < ;0) {cvErode ( SRC ,DST ,element ,1 ) ;cvDilate ( DST ,DST ,element ,1) ;} else {cvDilate ( SRC ,DST ,element ,1 ;cvErode ( DST ,d ) St ,element ,1) ;} cvReleaseStructuringElement ( & ;element ) ;cvShowImage ( " ;Open / Close" ;,DST ) ;} / / callback function for erode / dilate trackbarvoid ErodeDilate ( int POS ) {int n = erode_dilate_pos max_iters ;int an = n > ;0 ?N :- N ;element = cvCreateStructuringElementEx ( an * 2+1 ,an * 2+1 ,an ,an ,element_shape ,if ( 0 ) ;n < ;0) {cvErode ( SRC ,DST ,element ,1) ;} else {cvDilate ( SRC ,DST ,element ,1) ;} cvReleaseStructuringElement ( & ;element ;cvShowImage ( " ) ;Erode / Dilate" ,DST ) ;} ;int main ( int argc ,char * * argv ) {char * filename = argc = = 2 ?Argv :( char * ) " ;baboon.
jpg" ;if ;( ( SRC = cvLoadImage ( filename ,1) ) = = 0 ) return 1 ( " ;printf ;Hot keys: n" ;" ;tESC quit the program n" ;" ;tr use rectangle structuring element n" ;" ;te use elliptic structuring element n" ;" ;use cross-shaped structuring element TC n" tENTER - loo ;" ;P through all the options n" ;) ;DST = cvCloneImage ( SRC ) ;/ / create windows for output images cvNamedWindow ( " ;Open / Close" ;,Moncler Sale,1) ;cvNamedWindow ( " ;Erode / Dilate" ;,1) ;open_close_pos = erode_dilate_pos = max_iters ;cvCreateTrackbar ( " ;iterations" ;Open ," ;/ Close" ;& ;open_close_pos ,max_iters ,2+1 ,OpenClose ) ;cvCreateTrackbar ( " ;iterations" ;" ;Erode / Dilate" ,& ;erode_dilate_pos ,max_iters ;,* 2+1 ,ErodeDilate ) ;for ( ;;) {int c ;OpenClose ( open_close_pos ) ;ErodeDilate ( erode_dilate_pos ;C = cvWaitKey ( 0 ) ( ) ;if ( char ) C = = 27 ) break ;if ( C ( char ) = = = = = = = = = = = = element_shape = CV_SHAPE_ELLIPSE ) ;if ( else ( char ) C = = R ) element_shape = CV_SHAPE_RECT ;if ( else ( char ) C = = C ) element_shape = CV_SHAPE_CROSS ;else if ( C ( char ) = = = = = = = = = = = = ) element_shape = ( element_shape + 1 ) % 3 ;} / / release images cvReleaseImage ( & ;SRC ;c ) VReleaseImage ( & ;DST ) ;/ / destroy windows cvDestroyWindow ( " ;Open / Close" ;) ;cvDestroyWindow ( " ;Erode / Dilate" ;return 0 ;} ) ;operation results map: Note: in this example of open operation and close operation is through corrosion expansion to achieve, in OpenCV package has a good opening and closing operations can directly call .
The function void cvMorphologyEx ( const CvArr * SRC ,CvArr * DST ,CvArr * temp ,IplConvKernel * element ,Moncler Online Shop,int operation ,int iterations = 1 ) reference: 1.2 .To learn OpenCV ,Yu Shiqi
Related articles:

No comments:

Post a Comment