Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <opencv2/opencv.hpp>
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <vector>
- using namespace cv;
- using namespace std;
- String folderpath = "C:/Users/Junior/Desktop/Segmentação atualizada 05-06-16/FiltroRosa*.jpg";
- vector<String> filenames;
- vector<string> split(string str, char delimiter) {
- vector<string> internal;
- stringstream ss(str); // Turn the string into a stream.
- string tok;
- while (getline(ss, tok, delimiter)) {
- internal.push_back(tok);
- }
- return internal;
- }
- int main()
- {
- cv::glob(folderpath, filenames);
- int a = 0;
- for (size_t i = 0; i<filenames.size(); i++)
- {
- //printf("%d\n", i);
- Mat bw = imread(filenames[i], CV_LOAD_IMAGE_GRAYSCALE);
- cout << size(bw) << endl;
- string str = filenames[i];
- Mat labelImage(bw.size(), CV_32S);
- cout << size(labelImage) << endl;
- Mat erode1, dilate1;
- int erosion_size = 3;
- Mat element = getStructuringElement(cv::MORPH_ELLIPSE,
- cv::Size(2 * erosion_size + 1, 2 * erosion_size + 1),
- cv::Point(erosion_size, erosion_size));
- erode(bw, erode1, element);
- dilate(erode1, dilate1, element);
- vector<string> sep = split(str, '\\');
- int contador;
- string temp;
- for (contador = 0; contador < sep.size(); ++contador)
- {
- //cout << sep[contador] << endl;
- temp = sep[contador];
- //system("pause");
- }
- //mostra ou salva dst para cada label
- string strDst = temp + '_' + to_string(label) + ".jpg";
- cout << strDst << endl;
- cout << bw.size() << endl;
- cout << size(dst) << endl;
- imwrite(strDst, dst);
- //imshow(strDst, dst);
- //waitKey();
- //destroyWindow(strDst);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement