Escolar Documentos
Profissional Documentos
Cultura Documentos
Ejercicio 5.2
Smooth
Imagen original
#include "cv.h"
#include "highgui.h"
// Do the smoothing
//
cvSmooth( image, out, CV_GAUSSIAN, 5,5 );
cvSmooth( out, out, CV_GAUSSIAN, 5, 5);
// Show the smoothed image in the output window
//
cvShowImage( "Example2_4-out", out );
// Be tidy
//
cvReleaseImage( &out );
// Wait for the user to hit a key, then clean up the windows
//
cvWaitKey( 0 );
cvDestroyWindow("Example2_4-in" );
cvDestroyWindow("Example2_4-out" );
a. ¿Qué encontraste?
Se observa un efecto de partición de partículas, de manera tal como un desenfoque.
Smooth Gaussian 9X9
b. ¿Qué encontraste?
Se observa al igual que la imagen de 5X5 como el punto se esparce dentro de la imagen
similar a la expansion de particulas
VS
#include <stdio.h>
#include <cv.h>
#include <highgui.h>
// Temporary storage.
IplImage* s = cvCreateImage( cvGetSize(src), IPL_DEPTH_8U, 1 );
cvReleaseImage( &r );
cvReleaseImage( &g );
cvReleaseImage( &b );
cvReleaseImage( &s );
}
}
Primeramente se pide familiarizar con conceptos del threshold que maneja el OPENCV
CV_THRESHOLD_BINARY
CV_THRESHOLD_BINARY_INV
CV_THRESHOLD_TRUNC
CV_THRESHOLD_TOZERO_INV
CV_THRESHOLD_TOZERO
ADAPTIVE THRESHOLDS
#include <stdio.h>
#include <cv.h>
#include <highgui.h>
void sum_rgb( IplImage* src, IplImage* dst ) {
// Allocate individual image planes.
IplImage* r = cvCreateImage( cvGetSize(src), IPL_DEPTH_8U, 1 );
IplImage* g = cvCreateImage( cvGetSize(src), IPL_DEPTH_8U, 1 );
IplImage* b = cvCreateImage( cvGetSize(src), IPL_DEPTH_8U, 1 );
// Split image onto the color planes.
cvSplit( src, r, g, b, NULL );
// Temporary storage.
IplImage* s = cvCreateImage( cvGetSize(src), IPL_DEPTH_8U, 1 );
// Add equally weighted rgb values.
cvAddWeighted( r, 1./3., g, 1./3., 0.0, s );
cvAddWeighted( s, 2./3., b, 1./3., 0.0, s );
// Truncate values above 100.
cvReleaseImage( &r );
cvReleaseImage( &g );
cvReleaseImage( &b );
cvReleaseImage( &s );
}
int main(int argc, char** argv)
{
// Create a named window with the name of the file.
cvNamedWindow( argv[1], 1 );
// Load the image from the given file name.
IplImage* src = cvLoadImage( argv[1] );
IplImage* dst = cvCreateImage( cvGetSize(src), src->depth, 1);
sum_rgb( 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( 10 )&0x7f) == 27 ) break; }
// Clean up and don’t be piggies
cvDestroyWindow( argv[1] );
cvReleaseImage( &src );
cvReleaseImage( &dst );
}
ADAPTIVE THRESHOLD PARAM1=5 THRESHOLD BINARY