Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <opencv2/core/core.hpp>
- #include <opencv2/imgproc/imgproc.hpp>
- #include <opencv2/highgui/highgui.hpp>
- #include <iostream>
- #include <cstdlib>
- #include <fstream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- using namespace cv;
- using namespace std;
- int
- main(int argc, char *argv[])
- {
- FILE *fpo;
- //ofstream out_img;
- //out_img.open(argv[2],ios::out | ios::binary);
- fpo=fopen(argv[2],"wb");
- float up;
- up=atof(argv[3]);
- cout << "check0\n" <<endl;
- Mat src_img = imread(argv[1], 2);
- //Mat src_img = imread("depth_0010-01.tif", 2);
- if(src_img.empty()) return -1;
- //Mat dst_img1;
- Mat dst_img2(src_img.rows*up, src_img.cols*up, CV_32FC1);
- cout << "check0-1\n" <<endl;
- //float *buffer;
- //buffer=(float *)malloc(dst_img2.rows*dst_img2.cols*sizeof(float));
- cout << "check0-2\n" <<endl;
- // INTER_LINER(バイリニア補間)でのサイズ変更
- //resize(src_img, dst_img1, Size(), 0.3, 0.3);
- // INTER_CUBIC(バイキュービック補間)でのサイズ変更
- //resize(src_img, dst_img2, dst_img2.size(), INTER_CUBIC);
- resize(src_img,dst_img2,Size(),up,up,0);
- //namedWindow("resize image1", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO);
- namedWindow("resize image2", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO);
- //imshow("resize image1", dst_img1);
- //imshow("resize image2", dst_img2);
- cout << "check1\n" <<endl;
- cout << dst_img2.rows*dst_img2.cols << endl;
- //float dn;
- /*
- for(int i=0;i<src_img.rows*3; i++)
- {
- for(int j=0;j<src_img.cols*3; j++)
- {
- //out_img.put(dst_img2.data[i]);
- // dn=(int)(dst_img2.data[i*dst_img2.cols+j]*10);
- // cout << dst_img2.data[i*dst_img2.cols+j] <<endl;
- //cout << i <<endl;
- //printf("%f\n",dn);
- //out_img.put(dst_img2.data[i*dst_img2.cols+j]);
- dn=dst_img2.data[i*src_img.cols*3+j];
- //out_img.write(dn,1);
- //out_img <<
- //fwrite(
- //printf("%f\n",dn);
- fwrite(&dn,sizeof(float),1,fpo);
- }
- }
- */
- //out_img.write(dst_img2.data,dst_img2.rows*dst_img2.cols);
- fwrite(dst_img2.data,sizeof(float),dst_img2.rows*dst_img2.cols,fpo);
- cout << "check2\n" <<endl;
- //imwrite("output.tif",dst_img2);
- fclose(fpo);
- waitKey(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement