You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.
OpenCV, like PIL, has a lot of built-in functionality that can be done just as easily with Numpy. I think this would be a better way to do things with the students, so that we scaffold on the work we’ve already done with them.
For example, suppose we’ve loaded the car.jpg image as “image” with cv. Then “image” gets treated as a Numpy array. Hence, to convert RGB to BGR we could simply do this:
image=image[:,:,::-1] #reverse the order of B,G,R
or this:
image[:,:,[0,2]]=image[:,:,[2,0]] #swap B and R
Horizontal and vertical flips are similar:
image=image[::-1,:,:] #Flip across horizontal axis
and
image=image[:,::-1,:] #Flip across vertical axis
Here’s a vertical compression by a factor of 2:
image=image[::2,:,:]
The text was updated successfully, but these errors were encountered:
OpenCV, like PIL, has a lot of built-in functionality that can be done just as easily with Numpy. I think this would be a better way to do things with the students, so that we scaffold on the work we’ve already done with them.
For example, suppose we’ve loaded the car.jpg image as “image” with cv. Then “image” gets treated as a Numpy array. Hence, to convert RGB to BGR we could simply do this:
image=image[:,:,::-1] #reverse the order of B,G,R
or this:
image[:,:,[0,2]]=image[:,:,[2,0]] #swap B and R
Horizontal and vertical flips are similar:
image=image[::-1,:,:] #Flip across horizontal axis
and
image=image[:,::-1,:] #Flip across vertical axis
Here’s a vertical compression by a factor of 2:
image=image[::2,:,:]
The text was updated successfully, but these errors were encountered: