Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 months ago.
Improve this question
I used machine learning to cut out a portrait, but the result was a portrait, not a grayscale map, how do I convert it to a grayscale map? I want background is black and portrait is white
You can use skimage library to simply convert RGB to GrayScale image.
from skimage import color
from skimage import io
origImage = io.imread('your_image_path')
gsImage = color.rgb2gray(origImage)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Im looking for a method in python to read an image and identify its dimensions.
Also to read an image and reproduce the same image.
You can simply use the Pil librairy for the dimension
from PIL import Image
im = Image.open('filename.png')
print 'width: %d - height: %d' % im.size # returns (width, height) tuple
And for the copy it is even simpler, use:
Image.copy()
It copies this image. Use this method if you wish to paste things into an image, but still retain the original.
Using OpenCV, you can read an Image. OpenCV imread method is used to read image and it is stored numpy ndarray. You can get the dimensions using the size property.
eg:
img = cv2.imread('/path/to/image.png')
dimensions = img.shape
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
How to calculate absolute difference between two images using opencv and python?
Thanks in advance.
We'll assume that the two images are of the same size. Then, you can try this:
import cv2
import numpy as np
img1 = cv2.imread('path/to/img1')
img2 = cv2.imread('path/to/img2')
np.abs(img1, img2)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have raspberry pi and i generate code using python. That code captures a fisheye image, now I want a simple image, not a fisheye image. How do I remove that fisheye effect from the image or covert it into a simple image? I referred to some OpenCV site but couldn't find a solution..plz help me..Thanks in advance.
At this LINK you can find a useful tutorial for camera calibration in OpenCV.
It explains you the chessboard method to correct fish-eye distortions.
After calibration you can correct all pictures taken by camera.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Is there any simple way for converting PNG to PBM?
ocrad requires PBM image, not PNG.
Check out Pillow. According to the docs, it supports PBM, PGM, and PPM formats out of the box. The following code should get you started:
from PIL import Image
im = Image.open("myfile.png")
im.save("myfile.pbm")
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to process a lot of images using Python. All these images have some transparent region (alpha channel) of different sizes.
I need to programmatically fill in RGB noise in the transparent region of those images, but keep the non-transparent region unchanged. This is an example of changing the images.
How to do this programmatically in Python?
In my opinion you need to:
Create a Mat that contains Gaussian noise (or what kind of noise you need to add in the images).
For each image you copy the noise Mat into another one based on the alpha channel (used as mask)
Add the two images (initial and noise_mask) to he initial image (or the inital_noisy_background)