Extract irregularly shaped region from image using openCV - python

I am trying to learn OpenCV as I have an interest in Computer Vision and one kind of issue I am trying to tackle is extracting irregularly shaped regions from a given image. For example if I have a picture of this shoe:
Is there a way in which I can apply a mask to the image to extract ONLY the big Nike logo from the shoe image? Any insight will be much appreciated!

Related

Python Opencv: how to calculate the number of pixels that belong to the sky in a picture over total

I am currently learning opencv to process images in Python.
I have some pictures and I should detect which part of the picture represents the sky: then, I should calculate the number of pixels that belong to the sky over the total.
In your opinion, is there a way to do this with opencv or should I train a neural network to recognize the sky in a series of pictures?
Any help would be greatly appreciated. Thank you.
I tried thresholding, countouring, background subtraction in opencv
imho, a CNN for that is a bit overpowered. Personally, I would try to select all the correlated pixel, starting from a targeted one that surely represent the sky. (something like the luminance/color picker implemented in adobe camera raw)

How to extract object orientation from video stream (Webcam) - Python

I found this guide which teaches how to refine the orientation of objects from images. I would love to know if it can and should be used to analyze the orientation of objects displayed in video streams.
The basis for the work is from the scientific publication found in this video. I want to know how they got information about the direction of the Fish's face.
Thanks,
Avishai
You will probably need library like opencv to get orientation information from the image. You can apply threshold after converting this image to grayscale and extract contour of the image. After that you need to follow something like below pattern to get orientation. Very easy, just a little bit search you can find a lot of similar examples as well.
rectangle_for_angle = cv2.minAreaRect(cntrs[0])
angle = rectangle_for_angle[-1]
rect_points = cv2.boxPoints(rectangle_for_angle)
rect_points_result = np.int0(rect_points)
#You can also draw rotated image
cv2.drawContours(image,[rect_points_result],0,(0,0,255),2)

Images registration for low resolution highway images

I am using opencv with Python and I have a collection of images of highways. They have fixed resolution 352*288. They have been taken by mounted cameras, these cameras rotated horizontally and diagonally. I want to align this highways into piles,
I have tried feature passed images registration using SIFT, SURF and ORB. They are providing good results but when the image have rotation diagonally and when there is a small zooming the aligning will be damaged.
I have tried intensity based image registration using findTransformEcc and it is a little bit acceptable, but when I tried intensity based image registration using Matlab the results are much better.
example of images:
first image
second image

Imitating the "magic wand" photoshop tool in OpenCV

I'm trying to isolate the sky region from a series of grayscale images in OpenCV. All of the images are fairly similar: the top of the image is always a sky region, and is always a bright, gray-white colour. I've attempted contour-based approaches, and written my own algorithm to extract the line of the horizon and divide the image into two masks accordingly. However, I've noticed that the reliability of the magic wand tool in Photoshop on this image set is MUCH more accurate.
Here's the image that I'm processing:
and the result that I hope to achieve:
How can this be imitated in OpenCV?
I think what you're looking for is the grabcut algorithm

Homography of soccer field

Okay so i am trying to find homography of a soccer match. What i have till now is
Read images from a folder which is basically many cropped images of a template soccer field. Basically this has images for center circle and penalty lines etc.
Read video stream from a file and crop it into many smaller segments.
Loop inside the images in video stream and inside that another loop for images that i read from folder.
Now in the two images that i get through iteration , i applied a green filter because of my assumption that field is green
Use orb to find points and then find matches.
Now the Problem is that because of players and some noise from croud, i am unable to find proper matches for homography. Also removing them is a problem because that also tends to hide the soccer field lines that i need to calculate the homography on.
Any suggestions on this is greatly appreciated. Also below are some sample code and images that i am using.
"Code being used"
Sample images
Output that i am getting
The image on right of output is a frame from video and that on left is the same sample image that i uploaded after filterGreen function as can be seen from the code.
Finally what i want is for the image to properly map to center circle so i can draw a cube in center, Somewhat similar to "This example" . Thanks in advance for helping me out.
An interesting technique to throw at this problem is RASL. It computes homographies that align stacks of related images. It does not require that you specify corresponding points on the images, but operates directly on the image pixels. It is robust against image occlusions (eg, players moving in the foreground).
I've just released a Python implementation here: https://github.com/welch/rasl
(there are also links there to the original RASL paper, MATLAB implementation, and data).
I am unsure if you'd want to crop the input images to that center circle, or if the entire frames can be aligned. Try both and see.

Categories

Resources