Пример #1
0
void activeB()
{
    if (activeB2() == 1)
    {
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check1)))
        {
            g_print("\nBouton niveau de gris activé!\n");
            greyscale();
        }
        else
            g_print("\nBouton niveau de gris désactivé\n");

        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check2)))
        {
            g_print("\nBouton réduction du bruit activé!\n");
            bruit();
        }
        else
            g_print("\nBouton réduction du bruit désactivé\n");

        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check3)))
        {
            g_print("\nBouton de binarisation activé\n");
            binarise();
        }
        else
            g_print("\nBouton de binarisation désactivé\n");
    }
    else
        g_print("\nTout les traitements d'images sont désactivés...\n");
}
Пример #2
0
JNIEXPORT void JNICALL Java_makemachine_android_examples_Nati_greyscale(JNIEnv * env, jclass klass, jobject bitmap,jint wind){
      void * raw;
      uint32_t * pixels;
      int ret,j;
      int grey;
      AndroidBitmapInfo  info;
      if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) return;
      if ((ret = AndroidBitmap_lockPixels(env, bitmap, &raw)) < 0) return;
      pixels=(uint32_t*) raw;
#define USE_CONTRAST STRETCH
#ifdef USE_CONTRAST_STRETCH
      determine_contrast(&pixels,info.height,info.width);
#else
      Qwe::mingrey=0;
      Qwe::maxgrey=255;
#endif
      greyscale(&pixels,info.height,info.width);
      make_mean(info.height,info.width,wind);
#ifdef USE_DEVIATION
      make_dev(info.height,info.width,wind);
#endif
      imtoin(info.height,info.width);
      thresh(info.height,info.width);
      close(info.height,info.width,2);
      open(info.height,info.width,2);

      AndroidBitmap_unlockPixels(env, bitmap);

}
Пример #3
0
void Image::threshold(double d) {
    greyscale();
    for(int x = 0 ; x != width() ; ++x)
    for(int y = 0 ; y != height() ; ++y) {
        Color c = color_at(x, y);
        plot(x, y, (c.red() >= d && c.blue() >= d && c.green() >= d ? Color(1,1,1) :
                                                                      Color(0,0,0)));
    }
}
Пример #4
0
int
main (int argc, const char* const argv[])
{
    char garbage[2];
    int command;
    double sigma;

    if (4 > argc || 5 < argc) {
        fprintf (stderr, 
	         "syntax: %s <input file> <output file> <command #> ...\n", 
	         argv[0]);
        return 2;
    }

    if (1 != sscanf (argv[3], "%d%1s", &command, garbage) || 
        1 > command || 3 < command) {
	fprintf (stderr, "Command must be from 1 to 3.\n");
	fprintf (stderr, "  1 -- gaussian filter   <sigma>\n");
	fprintf (stderr, "  2 -- greyscale\n");
	fprintf (stderr, "  3 -- invert colors\n");
	return 2;
    }

    if (1 == command && 
        (5 != argc ||
         1 != sscanf (argv[4], "%lf%1s", &sigma, garbage) || 
	 0 >= sigma || 100 <= sigma)) {
    	fprintf (stderr, "Sigma must be greater than 0 and less than 100.\n");
	return 2;
    }

    Image* inputImage = decode (argv[1]);
    printf ("Width: %d, height: %d\n", inputImage->width, inputImage->height);
    Image* outputImage = generateOutput (inputImage);

    int height = inputImage->height;
    int width  = inputImage->width;
    uint8_t* inRed    = inputImage->redChannel;
    uint8_t* inBlue   = inputImage->blueChannel;
    uint8_t* inGreen  = inputImage->greenChannel;
    uint8_t* inAlpha  = inputImage->alphaChannel;
    uint8_t* outRed   = outputImage->redChannel;
    uint8_t* outBlue  = outputImage->blueChannel;
    uint8_t* outGreen = outputImage->greenChannel;
    uint8_t* outAlpha = outputImage->alphaChannel;

    switch (command) {
	case 1: {
	    int radius = ceil (3 * sigma);
	    int fSize = 1 + 2 * radius;
	    double* gauss = malloc (sizeof (gauss[0]) * fSize * fSize);
	    gaussianFilter (gauss, sigma);
	    convolveImage (width, height, inRed, inGreen, inBlue, inAlpha, 
			   radius, gauss, outRed, outGreen, outBlue, outAlpha);
	    encode (argv[2], outputImage);
	    break;
	}
	case 2:
	    greyscale (width, height, inRed, inGreen, inBlue, inAlpha, 
	               gMonoMult, outRed, outGreen, outBlue, outAlpha);
	    encode (argv[2], outputImage);
	    break;
	case 3:
	    invertColors (width, height, inRed, inGreen, inBlue, inAlpha, 
	    		  outRed, outGreen, outBlue, outAlpha);
	    encode (argv[2], outputImage);
	    break;
    }

    freeImage (inputImage);
    freeImage (outputImage);

    return 0;
}
Пример #5
0
bool
Color::operator < (const Color& other) const
{
  return greyscale() < other.greyscale();
}
Пример #6
0
void SIFT::processImage(){
	
	// загрузка изображения
	std::string file_path = "C:\\sp\\p.jpg";
	IplImage * img = cvLoadImage( file_path.c_str() );
	if( !img ){
		printf( "Could not load image file: %s\n", file_path.c_str() );
		exit( -1 );
	}

	IplImage* full_color_img = img;
	img = greyscale( full_color_img );

	// get the image data
	int height = img->height;
	int width = img->width;
	int channels = img->nChannels;
	printf("Processing a %dx%d image with %d channels\n",height,width,channels);

	// create a window
	cvNamedWindow( "mainWin", CV_WINDOW_AUTOSIZE );
	cvMoveWindow( "mainWin", 400, 30 );

	int octaves = 4;
	int scales = 5;
	IplImage*** scale_space = generate_scale_space( img, octaves, scales );
	IplImage*** diff_of_gauss =	difference_scale_space( scale_space, octaves, scales );
	IplImage*** keypoint_imgs = keypoint_dog(diff_of_gauss, octaves, scales);

	std::ofstream fout( "C:\\sp\\mc.txt" );
	uchar* sample = (uchar*)diff_of_gauss[3][2]->imageData;
	
	for( int i = 0; i < diff_of_gauss[3][2]->height; ++i ) {
		for( int j = 0; j < diff_of_gauss[3][2]->width; ++j ) {
			fout << (int)sample[i*diff_of_gauss[3][2]->widthStep + j] << " ";
		}
		
		fout << "\n";
	}
	
	fout.flush();
	fout.close();
  
	IplImage * display_image = keypoint_imgs[ 3][0];
	cvShowImage( "mainWin", display_image );

	const char * outfile = "C:\\sp\\out.jpg";
	const char * del_outfile = "DEL /F C:\\sp\\out.jpg";
	std::ifstream fin( outfile );
	if (fin) {
		std::cout << "File found, deleting..." << std::endl;
		system(del_outfile);
		fin.close();
	}

	if( !cvSaveImage( outfile, display_image ) ){
		printf( "Could not save: %s\n", outfile );
	}
	
	// wait for a key
	cvWaitKey(0);

	// release the image
	cvReleaseImage(&img);
}