OpenCV for Python beginners So, I wrote how to execute the Python example in OpenCV (opencv directory) \ sources \ samples \ python2.
OpenCV-Python & Scikit-image-Addition to "Must-see" OpenCV-Python Tutorials "2" So, I showed how to download and execute the example from Distributor of Scikit-image.
"OpenCV-Python Tutorials", "Practical Computer Vision" and scikit-learn So, I showed how to download and execute the example from Distributor of scikit-learn.
These examples include the script and its required data as a set so you can get started. I was drawn to Python because of the appeal of OpenCV-Python, Scikit-image, and scikit-learn. The number of people coming is increasing.
In this article, I'll write some Python beginners to play with the Scikit-image example with a slight modification.
Reference article [Series] "CV programming using python and OpenCV" Part 8: OpenCV-python ① Image input / output and visualization (highGUI)) OpenCV-Python, scikit-image, scikit-learn all use a common data format. for that reason, You can replace the input data in the scikit-image example script with OpenCV-Python cv2.imread ("lena.jpg ") and so on. If you replace the input data, you will find various things.
Task: [Normalized Cut] (http://scikit-image.org/docs/dev/auto_examples/segmentation/plot_ncut.html#example-segmentation-plot-ncut-py)
Let's change the input image with the example of.
Let's change the size of the input image. Search for cv2.resize (). Image processing by python + Opencv 5 (resize) Since the return value of cv2.resize () is the reduced image, A feature of the Python library is that it is easy to distinguish between the input and output of a function.
[Normalized Cut] (http://scikit-image.org/docs/dev/auto_examples/segmentation/plot_ncut.html#example-segmentation-plot-ncut-py)
Let's reduce the input image in half and operate it with the example of.
OpenCV-Python, scikit-image, and scikit-learn all use a common data format. For color images, specify subscripts in the order of img [y coordinate, x coordinate, BGR]. In grayscale images, it is a subscript of gray [y coordinate, x coordinate]. To know the size of the image [h, w] = img.shape[:2] [h, w] = gray.shape It will be. The range of the y coordinate has a minimum value of 0 and a maximum value of h-1. The x-coordinate range has a minimum value of 0 and a maximum value of w-1.
subImg = img[yu:yd, xl:xr, :] When, the point (yu, yd) is included in the partial image, Keep in mind that the yd and xr positions are not included in the partial image.
Reference article Split images with Python and OpenCV
Try using the above Normalized Cut to make the input image a partial image.
In the case of OpenCV-C ++, the data format of cv :: Mat is used. Also in this case cv::Mat img = cv2.imread("lena.jpg ", 0);
To access the elements of cv :: Mat
The first subscript is y and the second subscript is x.
This is common to both OpenCV-Python using numpy.array and OpenCV-C ++ using cv :: Mat.
img.at
Recommended Posts