-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
29 lines (26 loc) · 722 Bytes
/
main.cpp
File metadata and controls
29 lines (26 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
int main(){
Mat image, roi;
Rect crop;
int rows = 40, columns = 40;
image = imread("img.jpg");
int sizeX = image.size().height; //tinggi image sing diload
int sizeY = image.size().width; //lebar image sing diload
for (int i = 0; i < rows; i++){
for (int j = 0; j < columns; j++){
crop.x = j*sizeX/columns;
crop.y = i*sizeY/rows;
crop.width = sizeX/columns;
crop.height = sizeY/rows;
roi = image(crop);
std::stringstream printImage;
printImage << "path/"<< i << "_" << j << "_.jpg";
imwrite(printImage.str(), roi);
}
}
return 0;
}