image-processing

Contrast stretching in Python/ OpenCV

我是研究僧i 提交于 2020-07-05 04:16:09
问题 Searching Google for Histogram Equalization Python or Contrast Stretching Python I am directed to the same links from python documentation in OpenCv which are actually both related to equalization and not stretching (IMO). http://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/histogram_equalization/histogram_equalization.html http://docs.opencv.org/3.2.0/d5/daf/tutorial_py_histogram_equalization.html Read the documentation, it seems to be a confusion with the wording, as it describes

Hough Line Transform identifies only one line even though image contains many lines in OpenCV in Python

戏子无情 提交于 2020-07-05 03:49:14
问题 I used the Laplacian transform in OpenCV for edge detection and then used Hough Line Transform for detecting lines in it. These identified lines need to eventually removed from the image. import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('Feb_16-0.jpg',0) kernel = np.ones((1,1),np.uint8) opening = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel) blur = cv2.GaussianBlur(opening,(1,1),0) ret3,th4 = cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)

Reverse (remove) anti-aliasing filter

China☆狼群 提交于 2020-07-05 03:44:43
问题 I have a set of anti-aliased greyscale PNG images. I need to know how to programatically revert the anti-aliasing effect and get sharp edges again. I'm using GDI+ but I am less interested in code. I need an algorithm, maybe a convolution filter, if such a matrix can be built. The greyscale images (should) contain only 6 colors (or different shades of grey). This is so that later on I can re-color them using a Color-Lookup filter. However, when the images where saved, Photoshop automatically

Searching for a way to do Bitwise XOR on images

两盒软妹~` 提交于 2020-07-04 06:24:33
问题 I am looking for a way to get the Bitwise XOR of two images on the command line(or in another way that can be implemented in a program or script). This should result in the same final picture as using the XOR Blending mode in picture editors that support it (Paint.NET, Photoshop, etc) As an example, say I have Image A: and Image B: then the result should look like: The fun part of this is of course, that when you XOR image C with image B again, you will get an exact copy of image A. Now, I

Read Multiple images on a folder in OpenCv (python)

谁说胖子不能爱 提交于 2020-07-04 06:15:44
问题 I want to read multiple images on a same folder using opencv (python). To do that do I need to use for loop or while loop with imread funcion? If so, how? please help me... I want to get images into an array and then processed them one at a time through a loop. 回答1: import glob import cv2 images = [cv2.imread(file) for file in glob.glob("path/to/files/*.png")] 回答2: This will get all the files in a folder in onlyfiles . And then it will read them all and store them in the array images . from

Read Multiple images on a folder in OpenCv (python)

▼魔方 西西 提交于 2020-07-04 06:15:41
问题 I want to read multiple images on a same folder using opencv (python). To do that do I need to use for loop or while loop with imread funcion? If so, how? please help me... I want to get images into an array and then processed them one at a time through a loop. 回答1: import glob import cv2 images = [cv2.imread(file) for file in glob.glob("path/to/files/*.png")] 回答2: This will get all the files in a folder in onlyfiles . And then it will read them all and store them in the array images . from

Write pixel data in a grayscale image in java

断了今生、忘了曾经 提交于 2020-07-04 02:02:19
问题 I am developing a project on image processing where I have to fill the digitized images of cracked paintings. I have to convert a color image to grayscale, performing some calculations on the 2D Array of the gray image and writing it back as gray image. The code for this is: BufferedImage colorImage=ImageIO.read(new File(strImagePath)); BufferedImage image = new BufferedImage(colorImage.getWidth(),colorImage.getHeight(),BufferedImage.TYPE_BYTE_GRAY); Graphics g = image.getGraphics(); g

How to template match a simple 2D shape in OpenCV?

不问归期 提交于 2020-07-03 09:36:06
问题 I want to detect all pawns on a simple 2D chessboard. The problem is, my code only detects pawns on dark squares. I need all white pawns detected. Here's my set up: Chessboard ( full_board.png ): Pawn ( wp.png ): Expected output (detects all pawns): Actual output (not all pawns are detected): Code: import cv2 import numpy as np import imutils def main(): img = cv2.imread('full_board.png', 0) # Piece templates: img_rgb = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) img_gray = cv2.cvtColor(img_rgb,cv2

What is a joint histogram and a marginal histogram in image processing?

时间秒杀一切 提交于 2020-06-29 06:24:31
问题 What is a joint histogram and a marginal histogram in image processing and how do they work and how to construct one, with simple examples if possible. For example, if I have a feature space of 10 dimensions and want to build a histogram with each dimension quantize into 20 values. How to calculate the total bins for the joint histogram and for the marginal histogram? 回答1: I assume you know what histograms are in general. Joint histograms of data in an N-dimensional feature space are N

Preprocessing images for QR detection in python

泄露秘密 提交于 2020-06-29 04:23:11
问题 I used Zbar and OpenCV to read the QR code in the image below but both failed to detect it. For ZBar, I use pyzbar library as the python wrapper. There are images that QR is detected correctly and images really similar to the successful ones that fail. My phone camera can read the QR code in the uploaded image which means it is a valid one. Below is the code snippet: from pyzbar.pyzbar import decode from pyzbar.pyzbar import ZBarSymbol import cv2 # zbar results = decode(cv2.imread(image_path)