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 middle of the image
cv::Mat croppedImage = image(cropArea);
cv::imshow("image", image);
cv::imshow("cropped image", croppedImage);
cv::waitKey();
3: If you want to remove the cropped area of the image, then just do
image(cropArea).setTo(cv::Scalar(0, 0, 0, 0));
is the cropping done manually? the object is always in the same place? try to use a Rect like a ROI:
cv::imshow("object", image(roi));
Hi, thank you for your answer, but i don't have the permission to use function. I only can use C++ code. My project is: I have a image with a coin (entry image) and a must display the coin in his real dimension.
I write only this code jet: void main(){ char imagine = "C:\Users\Silvia\Desktop\procesare imagini\images2\T4.png"; IplImageimg = cvLoadImage(imagine); CvScalar currPixel; IplImage*imgLUM = cvLoadImage(imagine); for (int y = imgLUM->height/1.3; y > 0; y--) { for (int x = imgLUM->width/1.3; x < imgLUM->width; x++) { currPixel = cvGet2D(img, y, x); currPixel.val[0] = 255; currPixel.val[1] = 255; currPixel.val[2] = 255; cvSet2D(imgLUM, y, x, currPixel); } } cvShowImage("Image", img); cvShowImage("ImageNew", imgLUM); cvWaitKey(0); } How can i make it?
:-O C-api?? get rid of it!!! Another thing: you can edit your question with the code and format it as code so we can better understand it ;)
include "Tools.h"
It doesn't work to paste the code as code. Can you give me a emailadress? I can sent you the code if your welcome to help me with this university project
Hi, thank you for your answer, but i don't have the permission to use function --> euhm then how are you allowed to use OpenCV? OpenCV is a library of computer vision functions ...
@Denisa, please don't ask folks here to send you stuff privately. every useful comment/answer here should be available for anyone in need, right ?