Files
kepfeldolgozas/ora2/main4.cpp

48 lines
1.1 KiB
C++
Raw Normal View History

2025-10-02 16:00:02 +02:00
#include <algorithm>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
using namespace cv;
int main(){
Mat_<Vec3b> img = imread("kurama.jpg", IMREAD_COLOR); //ha itt meg van adva a templatebe a tipus akkor kesobb nem kella
//feher pontokat feketere:
//grayscale
/*for(int i = 0; i < img.rows; i++){
for(int j = 0; j < img.cols; j++){
if(img.at<uchar>(i,j) > 230){
img.at<uchar>(i,j) = 0;
}
}
}*/
Vec3b white(255,255,255);
Vec3b black(0,0,0);
for(int i = 0; i < img.rows; i++){
for(int j = 0; j < img.cols; j++){
/*if(img.at<Vec3b>(i,j)[0] > 230){ //[] melyik szin csatorna (bgr)
img.at<Vec3b>(i,j) = black;
}*/
//if(img(i,j)[0] > 230){
// img(i,j) = black;
//}
}
}
for(auto &p : img){
//csak akkor kell referencia ha modositani akarjuk
if(p[0] > 230){
p = black;
}
}
imshow("img", img);
waitKey();
return 0;
}