Exemplo n.º 1
0
int
main(int argc, char *argv[]) {

    struct cmdlineInfo cmdline;
    struct pam pam;
    sample ** pixels;       /* pixel data */
    unsigned int hsamples; /* horizontal samples used */
    unsigned int hstep;    /* horizontal step size */
    unsigned int vstep;    /* vertical step size */
    float angle;

    pgm_init(&argc, argv);              /* initialize netpbm system */

    parseCommandLine(argc, argv, &cmdline);

    readRelevantPixels(cmdline.inputFilename, cmdline.hstep, cmdline.vstep,
                       &hstep, &vstep, &pixels, &pam, &hsamples);

    replacePixelValuesWithScaledDiffs(&pam, pixels, hsamples, cmdline.dstep);

    getAngle(&pam, pixels, hstep, vstep, hsamples,
             cmdline.maxangle, cmdline.astep, cmdline.qmin,
             cmdline.fast, cmdline.verbose, &angle);

    /* report the result on stdout */
    printf("%.2f\n", angle);

    freePixels(pixels, pam.height);

    return 0;
}
Exemplo n.º 2
0
int main ( int argc, char * argv[] ) {

	if ( argc < 2 ) errorMessage( 1, "Missing Arguments" );
	if ( argc > 3 ) errorMessage( 2, "Too many Arguments" );

	IplImage *img = NULL;
	img = cvLoadImage( argv[1], 1 );

	// pixels [y][x][c]
	uchar *** pixels = NULL;
	pixels = getPixels( img );

	char key;

	do {

		key = (char) cvWaitKey(1);

		if ( key == 'n' ) normalize( img, pixels );
		if ( key == 'i' ) invert( img, pixels );
		if ( key == 'h' ) cvFlip( img, img, 1 );

		if ( key == 'l' ) {

			IplImage *tmp = NULL;
			tmp = rotate( img, pixels );

			freePixels( img->height, pixels );
			cvReleaseImage( &img );

			img = tmp;
			pixels = getPixels( img );
		}

		cvShowImage("rgbviewer", img );

	} while ( key != 'q' ); // quit

	// release the image & reference ( tmp )
	freePixels( img->height, pixels );
	cvReleaseImage( &img );

	return 0;
}