In my application, I need to compare 2 images and highlight the difference with color. For example, I am comparing UIImage1 with UIImage2, where both the images are same, except there is a small square in UIImage2. I need to highlight the extra square object with red color and display in the image view otherwise I want to know the x and y-direction of the difference.
I have tried this below code. in this code, I can only change the alpha value of the difference. can't change the color of the diff.
UIImage* bottomImage = [UIImage imageNamed:@"j1.jpg"];
UIImage* topImage = [UIImage imageNamed:@"j2.jpg"];
UIImageView* imageView = [[UIImageView alloc] initWithImage:bottomImage];
UIImageView* subView = [[UIImageView alloc] initWithImage:topImage];
subView.alpha = 0.5; // Customize the opacity of the top image.
[imageView addSubview:subView];
UIGraphicsBeginImageContext(imageView.frame.size);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* blendedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
_imageview.image = blendedImage;
image 1:
image 2:
diff image:
but what I want is this:
I'm new to OpenCV the codes are in python. can anyone help me to change this code into objective-c? I tried but I'm getting the error only.
https://stackoverflow.com/a/27500479/6859041
im = cv2.imread('c:\\diff.jpg')
im1 = cv2.imread('c:\\Edited.jpg')
imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray,127,255,0)
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(im1, contours, -1, (0,255,0), 1)
cv2.imwrite("c:\\see_this.jpg", im1)
how to change this code into objective C?
thanks.