Browse files

Cleaned up src folder

  • Loading branch information...
1 parent b1ec307 commit 32f6908ef1b9886ac0d7a879425c4a39e21e66ca @Mooble Mooble committed Apr 14, 2012
Showing with 71 additions and 129 deletions.
  1. +1 −1 src/{ → pocs}/Makefile
  2. +1 −0 src/pocs/test.sh
  3. +69 −53 src/{ → pocs}/test_resize.cpp
  4. +0 −74 src/register_Image_INC.cpp
  5. BIN src/resize_test
  6. +0 −1 src/test.sh
View
2 src/Makefile → src/pocs/Makefile
@@ -1,4 +1,4 @@
resize_test: test_resize.cpp
g++ -o resize_test test_resize.cpp -I/usr/include/opencv -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_legacy -lopencv_flann
clean:
- rm -rf resize_test
+ rm -rf resize_test;
View
1 src/pocs/test.sh
@@ -0,0 +1 @@
+./resize_test /usr/share/pixmaps/faces/coffee.jpg
View
122 src/test_resize.cpp → src/pocs/test_resize.cpp
@@ -28,31 +28,46 @@ int main(int argc, char* argv[]){
IplImage *bigger_image;
IplImage *rotated_image;
IplImage *shifted_image;
+ IplImage *shifted_image2;
+ IplImage *shifted_image3;
+ IplImage *shifted_image4;
//Read in Image
image = cvLoadImage(argv[1], CV_LOAD_IMAGE_COLOR);
//Transform image
bigger_image = resizeImage(image,image->width*rescale_factor,image->height*rescale_factor,false);
rotated_image = rotateImage(image,180);
- shifted_image = shiftImageRot(image,-50,0);
+ shifted_image = shiftImageRot(image,0,25);
+ shifted_image2 = shiftImageRot(image,0,-25);
+ shifted_image3 = shiftImageRot(image,25,0);
+ shifted_image4 = shiftImageRot(image,-25,0);
//Show all the images
namedWindow( "original", CV_WINDOW_AUTOSIZE );
namedWindow( "bigger", CV_WINDOW_AUTOSIZE );
namedWindow( "rotated", CV_WINDOW_AUTOSIZE );
namedWindow( "shifted", CV_WINDOW_AUTOSIZE );
+ namedWindow( "shifted2", CV_WINDOW_AUTOSIZE );
+ namedWindow( "shifted3", CV_WINDOW_AUTOSIZE );
+ namedWindow( "shifted4", CV_WINDOW_AUTOSIZE );
cvShowImage( "original", image );
cvShowImage( "bigger", bigger_image );
cvShowImage( "rotated", rotated_image );
cvShowImage( "shifted", shifted_image );
+ cvShowImage( "shifted2",shifted_image2 );
+ cvShowImage( "shifted3",shifted_image3 );
+ cvShowImage( "shifted4",shifted_image4 );
waitKey(0);
//Release memory
cvReleaseImage(&image);
cvReleaseImage(&bigger_image);
cvReleaseImage(&rotated_image);
cvReleaseImage(&shifted_image);
+ cvReleaseImage(&shifted_image2);
+ cvReleaseImage(&shifted_image3);
+ cvReleaseImage(&shifted_image4);
return 0;
}
@@ -205,7 +220,7 @@ IplImage *shiftImage(const IplImage *src, int vertical, int horizontal){
imageShifted = cvCreateImage(size, src->depth, src->nChannels);
origImage = cvCreateImage(size, src->depth, src->nChannels);
cvCopy(src,origImage);
-
+
oppositeDirection = (vertical < 0);
if(oppositeDirection){
vertical *= -1;
@@ -267,83 +282,84 @@ IplImage *shiftImageRot(const IplImage *src, int vertical, int horizontal){
imageShifted = cvCreateImage(size, src->depth, src->nChannels);
origImage = cvCreateImage(size, src->depth, src->nChannels);
cvCopy(src,origImage);
-
- oppositeDirection = (vertical < 0);
- if(oppositeDirection){
- vertical *= -1;
- }
- //Copy 1st portion
- if(oppositeDirection){
- origRegion = cvRect( 0, vertical, src->width, src->height );
- shiftedRegion = cvRect( 0, 0, src->width, src->height-vertical );
- }else{
- origRegion = cvRect( 0, 0, src->width, src->height - vertical);
- shiftedRegion = cvRect( 0, vertical, origRegion.width, origRegion.height );
- }
+ if(vertical != 0 ){
+ oppositeDirection = (vertical < 0);
+ if(oppositeDirection){
+ vertical *= -1;
+ }
- cvSetImageROI(origImage,origRegion);
- cvSetImageROI(imageShifted,shiftedRegion);
+ //Copy 1st portion
+ if(oppositeDirection){
+ origRegion = cvRect( 0, vertical, src->width, src->height-vertical );
+ shiftedRegion = cvRect( 0, 0, src->width, src->height - vertical);
+ }else{
+ origRegion = cvRect( 0, 0, src->width, src->height - vertical);
+ shiftedRegion = cvRect( 0, vertical, src->width, src->height - vertical );
+ }
- cvCopy(origImage, imageShifted);
+ cvSetImageROI(origImage,origRegion);
+ cvSetImageROI(imageShifted,shiftedRegion);
- //Copy 2nd portion
- if(oppositeDirection){
- origRegion = cvRect( 0, 0, src->width, vertical );
- shiftedRegion = cvRect( 0, src->height-vertical, origRegion.width, src->height );
- }else{
- origRegion = cvRect( 0, src->height - vertical, src->width, src->height );
- shiftedRegion = cvRect( 0, 0, origRegion.width, vertical);
- }
+ cvCopy(origImage, imageShifted);
- cvSetImageROI(origImage,origRegion);
- cvSetImageROI(imageShifted,shiftedRegion);
+ //Copy 2nd portion
+ if(oppositeDirection){
+ origRegion = cvRect( 0, 0, src->width, vertical);
+ shiftedRegion = cvRect( 0, src->height - vertical, src->width, vertical );
+ }else{
+ origRegion = cvRect( 0, src->height - vertical, src->width, vertical );
+ shiftedRegion = cvRect( 0, 0, src->width, vertical);
+ }
- cvCopy(origImage, imageShifted);
+ cvSetImageROI(origImage,origRegion);
+ cvSetImageROI(imageShifted,shiftedRegion);
- /*
- cvSetImageROI(origImage,origRegion);
- cvSetImageROI(imageShifted,shiftedRegion);
+ cvCopy(origImage, imageShifted);
- cvCopy(origImage, imageShifted);
+ //Copy changes to origImage, so next steps don't overwrite
+ cvResetImageROI(imageShifted);
+ cvResetImageROI(origImage);
+ cvCopy(imageShifted,origImage);
+ }
- cvResetImageROI(imageShifted);
- cvResetImageROI(origImage);
- cvCopy(imageShifted,origImage);
+ if( horizontal != 0 ){
+ oppositeDirection = (horizontal < 0);
+ if(oppositeDirection){
+ horizontal *= -1;
+ }
- oppositeDirection = (horizontal < 0);
- if(oppositeDirection){
- horizontal *= -1;
- }
- for(int i = 1; i <= horizontal && i < src->width; i++){
+ //Copy 1st portion
if(oppositeDirection){
- origRegion = cvRect( i, 0, origRegion.width, origRegion.height);
- shiftedRegion = cvRect( 0, 0, src->width - i, src->height );
+ origRegion = cvRect( horizontal, 0, src->width - horizontal, src->height );
+ shiftedRegion = cvRect( 0, 0, src->width - horizontal, src->height);
}else{
- origRegion = cvRect( 0, 0, src->width - i, src->height);
- shiftedRegion = cvRect( i, 0, origRegion.width, origRegion.height);
+ origRegion = cvRect( 0, 0, src->width - horizontal, src->height);
+ shiftedRegion = cvRect( horizontal, 0, src->width - horizontal, src->height );
}
+
cvSetImageROI(origImage,origRegion);
cvSetImageROI(imageShifted,shiftedRegion);
cvCopy(origImage, imageShifted);
-
+
+ //Copy 2nd portion
if(oppositeDirection){
- origRegion = cvRect( 0, 0, i, origRegion.height);
- shiftedRegion = cvRect( src->width - i, 0, src->width, src->height );
+ origRegion = cvRect( 0, 0, horizontal, src->height);
+ shiftedRegion = cvRect( src->width - horizontal, 0, horizontal, src->height );
}else{
- origRegion = cvRect( src->width - i, 0, src->width, src->height);
- shiftedRegion = cvRect( 0, 0, i, origRegion.height);
+ origRegion = cvRect( src->width - horizontal, 0, horizontal, src->height );
+ shiftedRegion = cvRect( 0, 0, horizontal, src->height);
}
+
cvSetImageROI(origImage,origRegion);
cvSetImageROI(imageShifted,shiftedRegion);
cvCopy(origImage, imageShifted);
}
- */
+
+ //Reset region of interest
cvResetImageROI((IplImage*)src);
cvResetImageROI(imageShifted);
return imageShifted;
}
-
-
View
74 src/register_Image_INC.cpp
@@ -1,74 +0,0 @@
-#ifdef +MSC_VER
- //XXX: Need something here?
-#else
- #include <opencv/cv.h>
- #include <opencv2/core/core.hpp>
- #include <opencv2/highgui/highgui.hpp>
-#enfid
-#include <iostream>
-
-using namespace std;
-using namespace cv;
-
-IplImage* register_Image(const IplImage* img1, const IplImage* img2, int &shx, int &shy)
-{
-//&shift id should passed in as something unfilled and is really another return value
-// there is definitely a better way to do this but when you leave this function
-// you need the resulting image AND the shifts that have been applied to it
-
- IplImage* oim1, oim2; //original images
- CvSize size1, size2; //image sizes
- size1.width = img1->width;
- size1.height = img1->height;
-
- size2.width = img1->width;
- size2.height = img2->height;
-
- oim1 = cvCreateImage(size, img1->depth, 1);
- oim2 = cvCreateImage(size, img2->depth, 1);
- cvCopy(img1, oim1); cvCopy(img2, oim2); //create copies
-
- Mat kernel = generate_Kernel_Window(img1, 0.05, 0.05) //external function
- //assuming image 1 and 2 are the same size
-
- if (kernel->width != img1->width || kernel->width != img1->width)
- {
- cout << "ERROR: Image1 width is " << kernel->width
- << "expected " << kernel->width << "\n";
- exit(1);
- }
- //TODO: More sanity checking for img1 and img2
-
- //source1, source2, destination
- Multiply(img1, kernel, img1); // member by member multiply
- Multiply(img2, kernel, img2); // cv functions, check output
-
- int avg1, avg2;
- avg1 = Avg(img1); //cv function, check this output
- avg2 = Avg(img2);
-
- img1 = img1 / avg1; //matrix operation on image
- img2 = img2 / avg2; //this can't be right
-
- //XXX: We have to do FFTs here and there aren't in OpenCV
- // check for FFTW online (makefiles will need a change)
- //
- // Don't know the math on this, just copying the matlab code
- IblImage temp, f;
- temp = FFT(img1) .* fft(rotateImage(img2, 180)); //external function
- f = FFT_Shift(abs(inverse_FFT(temp));
- //XXX: FFT_Shift could pose a problem Grant has a link for it, but ???
- // inverse should be included with FFTW
-
- find maximum value in f;
- shift_id = location of that value;
-
- //XXX: Don't understand this part of the matlab yet, this isn't done
- // make a point based on the middle of the image
- sh(1)=(mod(shid-1,size(im1,1))+1)-size(im1,1)/2;
- sh(2)=ceil((shid-1)/size(im1,1))-size(im1,2)/2;
- //shift the image based on the (new) midpoint?
- //this is still somewhat unclear
-
- return shift_image(oim2,sh); //external function
-}
View
BIN src/resize_test
Binary file not shown.
View
1 src/test.sh
@@ -1 +0,0 @@
-./resize_test /usr/share/pixmaps/faces/coffee.jpg

0 comments on commit 32f6908

Please sign in to comment.