1 | initial version |
I am pretty sure that your problem is the C-api... apart that you are displaying a white image instead of crop; so:
Switch to C++:
void main(){ std::string imagine = "C:\Users\Silvia\Desktop\procesare imagini\images2\T4.png"; cv::Mat img = cv::imread(imagine); cv::Scalar currPixel; cv::Mat imgLUM = cv::imreadimagine); for (int y = imgLUM.rows/1.3; y > 0; y--) { for (int x = imgLUM.cols/1.3; x < imgLUM.cols; x++) { // ??? } } cv::imshow("Image", img); cv::imshow("Image2", imgLUM); cv::waitKey(0); }
Then do a crop:
cv::Mat image = cv::imread(imagine); cv::Rect cropArea(image.cols/3, image.rows/3, image.cols/3, image.rows/3); // play with values to obtain what you need, now it is the meddle of the image cv::Mat croppedImage = image(cropArea); cv::imshow("image", image); cv::imshow("cropped image", croppedImage); cv::waitKey();
If you want to remove the cropped area of the image, then just do
image(cropArea).setTo(cv::Scalar(0, 0, 0, 0));
2 | No.2 Revision |
I am pretty sure that your problem is the C-api... apart that you are displaying a white image instead of crop; so:
1:
Switch to C++:
void main(){
std::string imagine = "C:\Users\Silvia\Desktop\procesare imagini\images2\T4.png";
cv::Mat img = cv::imread(imagine);
cv::Scalar currPixel;
cv::Mat imgLUM = cv::imreadimagine);
for (int y = imgLUM.rows/1.3; y > 0; y--)
{
for (int x = imgLUM.cols/1.3; x < imgLUM.cols; x++)
{
// ???
}
}
cv::imshow("Image", img);
cv::imshow("Image2", imgLUM);
cv::waitKey(0);
2:
Then do a crop:
cv::Mat image = cv::imread(imagine);
cv::Rect cropArea(image.cols/3, image.rows/3, image.cols/3, image.rows/3); // play with values to obtain what you need, now it is the 3:
If you want to remove the cropped area of the image, then just do
image(cropArea).setTo(cv::Scalar(0, 0, 0,