Examen Juan
-
Upload
juan-barrios-aviles -
Category
Documents
-
view
216 -
download
0
Transcript of Examen Juan
-
8/14/2019 Examen Juan
1/11
INSTITUTO TECNOLGICO Y DE ESTUDIOS SUPERIORES DE MONTERREYSISTEMAS DE VISION POR COMPUTADORAJUAN BARRIOS AVILS887586EJERCICIOS OPENCV
Ejercicio 5.2Smooth
Imagen original
#include "cv.h"#include "highgui.h"
void example2_4( IplImage* image ){
// Create some windows to show the input// and output images in.//cvNamedWindow( "Example2_4-in", CV_WINDOW_AUTOSIZE );cvNamedWindow( "Example2_4-out", CV_WINDOW_AUTOSIZE );
// Create a window to show our input image//cvShowImage( "Example2_4-in", image );
// Create an image to hold the smoothed output//IplImage* out = cvCreateImage(
cvGetSize(image),
IPL_DEPTH_8U,3
);
// Do the smoothing//cvSmooth( image, out, CV_GAUSSIAN, 5,5 );cvSmooth( out, out, CV_GAUSSIAN, 5, 5);
-
8/14/2019 Examen Juan
2/11
// 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" );
}
int main( int argc, char** argv ){
IplImage* img = cvLoadImage( argv[1] );cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE );cvShowImage("Example1", img );example2_4( img );
// cvWaitKey(0);cvReleaseImage( &img );cvDestroyWindow("Example1");
}
Smoothing Gaussian 5X5
a.
Qu encontraste?Se observa un efecto de particin de partculas, de manera tal como un desenfoque.
-
8/14/2019 Examen Juan
3/11
Smooth Gaussian 9X9
b. Qu encontraste?Se observa al igual que la imagen de 5X5 como el punto se esparce dentro de la imagensimilar a la expansion de particulas
Smooth Gaussian 5X5 dos veces VS Smooth Gaussian 9X9
VS
c. Son las imgenes parecidas?, por qu y por qu no?Debido a la dimensin del punto que se puso en la imagen es complicado encontrar unadiferencia sin embargo en teora el smooth gaussian de 5X5 doble debe presentar unmayor desenfoque debido a que se hace en dos tiempos diferentes y a dos imgenesdiferentes.
-
8/14/2019 Examen Juan
4/11
-
8/14/2019 Examen Juan
5/11
cvReleaseImage( &b );cvReleaseImage( &s );
}
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] );IplImage* dst = cvCreateImage( cvGetSize(src), src->depth, 1);sum_rgb( src, dst);
// Show the image in the named windowcvShowImage( argv[1], dst );
// Idle until the user hits the "Esc" key.while( 1 ) { if( (cvWaitKey( 10 )&0x7f) == 27 ) break; }
// Clean up and dont be piggiescvDestroyWindow( argv[1] );cvReleaseImage( &src );cvReleaseImage( &dst );
}
Primeramente se pide familiarizar con conceptos del threshold que maneja el OPENCVCV_THRESHOLD_BINARY
-
8/14/2019 Examen Juan
6/11
CV_THRESHOLD_BINARY_INV
CV_THRESHOLD_TRUNC
-
8/14/2019 Examen Juan
7/11
CV_THRESHOLD_TOZERO_INV
CV_THRESHOLD_TOZERO
-
8/14/2019 Examen Juan
8/11
ADAPTIVE THRESHOLDS
#include #include #include 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.
//cvThreshold( s, dst, 100, 100, CV_THRESH_TRUNC );cvAdaptiveThreshold(s, dst, 255, CV_ADAPTIVE_THRESH_MEAN_C,CV_THRESH_BINARY_INV, 3, -5); Lo que esta en amarillo muestra los parmetros que
fueron necesarios cambiar para lograr las imgenes que se pedan en la practica
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 windowcvShowImage( argv[1], dst );
// Idle until the user hits the Esc key.while( 1 ) { if( (cvWaitKey( 10 )&0x7f) == 27 ) break; }// Clean up and dont be piggiescvDestroyWindow( argv[1] );cvReleaseImage( &src );cvReleaseImage( &dst );}
-
8/14/2019 Examen Juan
9/11
ADAPTIVE THRESHOLD PARAM1=5 THRESHOLD BINARY
ADAPTIVE THRESHOLD PARAM1=5 THRESHOLD BINARY INV
-
8/14/2019 Examen Juan
10/11
ADAPTIVE THRESHOLD PARAM1=0 THRESHOLD BINARY
ADAPTIVE THRESHOLD PARAM1=0 THRESHOLD BINARY INV
-
8/14/2019 Examen Juan
11/11
ADAPTIVE THRESHOLD PARAM1=-5 THRESHOLD BINARY
ADAPTIVE THRESHOLD PARAM1=-5 THRESHOLD BINARY INV