cv2

How to get 2D array from 3D array of an image by removing black pixels, i.e. [0,0,0], in python

妖精的绣舞 提交于 2021-02-10 16:54:29
问题 I have a picture of the facial skin with black pixels around it. The picture is an 3d array made up of pixels (RGB) picture's array = width * height * RGB The problem is that in the picture there are so many black pixels that do not belong to the skin. The black pixels represent as an array of zero. [0,0,0] I want to get 2d array with non-black pixels as [[218,195,182]. ... [229,0, 133]] -with only the pixels of facial skin color I try to eject the black pixels by finding all the pixels whose

cv2 imread transparency gone

江枫思渺然 提交于 2021-02-10 12:19:51
问题 I have an image (a captcha) that I download from the web. When I loaded to opencv it seems to loose its properties or simply mixes the transparent background with the dark/black colors: Currently the code does nothing but loading a writing again: captchaImg = cv2.imread('captcha1.png') cv2.imwrite("captcha2.png", captchaImg) I have tried loading also with options 0, 1, 2, 3 but the result is the same. 回答1: Well this is a problem with opencv and it has a solution with opencv but it is kind of

cv2 imread transparency gone

牧云@^-^@ 提交于 2021-02-10 12:18:06
问题 I have an image (a captcha) that I download from the web. When I loaded to opencv it seems to loose its properties or simply mixes the transparent background with the dark/black colors: Currently the code does nothing but loading a writing again: captchaImg = cv2.imread('captcha1.png') cv2.imwrite("captcha2.png", captchaImg) I have tried loading also with options 0, 1, 2, 3 but the result is the same. 回答1: Well this is a problem with opencv and it has a solution with opencv but it is kind of

Color gets dull: opencv cv2.imread cv2.imwrite

∥☆過路亽.° 提交于 2021-02-08 13:15:38
问题 I am using opencv module to read and write the image. here is the code and below is the image i am reading and second image is after saving it on disk using cv2.imwrite(). import cv2 img = cv2.imread('originalImage.jpg') cv2.imwrite('test.jpg',img) It is significantly visible that colors are dull in second image. Is there any workaround to this problem or I am missing on some sort of setting parameters..? 回答1: The difference is that the initial image (on the left in the diagram) has an

Color gets dull: opencv cv2.imread cv2.imwrite

浪子不回头ぞ 提交于 2021-02-08 13:15:35
问题 I am using opencv module to read and write the image. here is the code and below is the image i am reading and second image is after saving it on disk using cv2.imwrite(). import cv2 img = cv2.imread('originalImage.jpg') cv2.imwrite('test.jpg',img) It is significantly visible that colors are dull in second image. Is there any workaround to this problem or I am missing on some sort of setting parameters..? 回答1: The difference is that the initial image (on the left in the diagram) has an

Color gets dull: opencv cv2.imread cv2.imwrite

随声附和 提交于 2021-02-08 13:14:46
问题 I am using opencv module to read and write the image. here is the code and below is the image i am reading and second image is after saving it on disk using cv2.imwrite(). import cv2 img = cv2.imread('originalImage.jpg') cv2.imwrite('test.jpg',img) It is significantly visible that colors are dull in second image. Is there any workaround to this problem or I am missing on some sort of setting parameters..? 回答1: The difference is that the initial image (on the left in the diagram) has an

Local Contrast Enhancement for Digit Recognition with cv2 / pytesseract

▼魔方 西西 提交于 2021-02-07 10:09:55
问题 I want to use pytesseract to read digits from images. The images look as follows: The digits are dotted and in order to be able to use pytesseract, I need black connected digits on a white background . To do so, I thought about using erode and dilate as preprocessing techniques. As you can see, the images are similar, yet quite different in certain aspects. For example, the dots in the first image are darker than the background, while the dots in the second are whiter. That means, in the

Local Contrast Enhancement for Digit Recognition with cv2 / pytesseract

不羁的心 提交于 2021-02-07 10:09:44
问题 I want to use pytesseract to read digits from images. The images look as follows: The digits are dotted and in order to be able to use pytesseract, I need black connected digits on a white background . To do so, I thought about using erode and dilate as preprocessing techniques. As you can see, the images are similar, yet quite different in certain aspects. For example, the dots in the first image are darker than the background, while the dots in the second are whiter. That means, in the

Using cv2.imread: “<built-in function imread> returned NULL without setting an error”, as if it can't open the picture or get the data

为君一笑 提交于 2021-02-07 06:05:57
问题 This is the part of my code that gives the problem. It is supposed to count the amount of green pixels in a picture: img = Image.open('path.tif') BLACK_MIN = np.array([0, 20, 20], np.uint8) BLACK_MAX = np.array([120, 255, 255], np.uint8) imgg = cv2.imread(img, 1) dst = cv2.inRange(imgg, BLACK_MIN, BLACK_MAX) no_black = cv2.countNonZero(dst) print('The number of black pixels is: ' + str(no_black)) 回答1: You are passing a PIL image to imread but it expects a filepath (https://docs.opencv.org/2.4

No module named 'cv2' error in new environment

坚强是说给别人听的谎言 提交于 2021-01-29 19:11:25
问题 I have tried to rectify this issue by using pip install opencv-python pip install opencv-contrib-python pip uninstall panda pip install panda conda install opencv-python Some info is that im currently using python 3.6.10 and Windows 10. opencv-python 4.2.0.32 numpy 1.18.1 panda 0.3.1 tensorflow-gpu 1.14.0 I created a new env but cant seem to import cv2 over on Jupyter Notebook. My earlier environment was able to do so. When i tried to pip install the opencv-python==4.1.2.30 (from the old