Questions tagged [binary-image]

Used for questions concerning images of two colors (usually black and white). Such images are common in object detection, edge detection, object counting etc.

A binary image is a digital image that has only two possible values for each pixel. Typically, the two colors used for a binary image are black and white, though any two colors can be used. The color used for the object(s) in the image is the foreground color while the rest of the image is the background color.

131 questions
4
votes
1 answer

How to connect disjointed lines or edges in images?

I am currently working on lines extraction from a binary image. I initially performed a few image processing steps including threshold segmentation and obtained the following binary image. As can be seen in the binary image the lines are splitted…
4
votes
2 answers

How to identify holes connected by lines in binary graph

I have picked up a code segement from the top voted author's answer from this question: https://answers.opencv.org/question/9863/fill-holes-of-a-binary-image/ Refomatted it as: cv::Mat image = cv::imread("image.jpg", 0); cv::Mat…
Kevin
  • 6,711
  • 16
  • 60
  • 107
4
votes
1 answer

Convert binary image data to image and display in HTML

I'm working with Musicbrainsngs - the Python lib for Musicbrainz API. Making a request for some album artwork. import musicbrainzngs as mb release_group_ID = '5c14fd50-a2f1-3672-9537-b0dad91bea2f' artwork =…
Will
  • 169
  • 1
  • 3
  • 12
3
votes
3 answers

Trouble getting accurate binary image OpenCV

Using the threshold functions in open CV on an image to get a binary image, with Otsu's thresholding I get a image that has white spots due to different lighting conditions in parts of the image or with adaptive threshold to fix the lighting…
3
votes
1 answer

Pillow - How to binarize an image with threshold?

I would like to binarize a png image. I would like to use Pillow if possible. I've seen two methods used: image_file = Image.open("convert_image.png") # open colour image image_file = image_file.convert('1') # convert image to black and white This…
Neil
  • 3,020
  • 4
  • 25
  • 48
3
votes
1 answer

Curve Fitting in a binary image, MATLAB

I have this Binary image bw: edges of an object to carry out some measurements. But firstly I have to do curve fitting for both edges. The result should be two smooth curves representing edges. I have the indices for each edge but I can not…
Mohamed Sayed
  • 93
  • 1
  • 3
  • 10
3
votes
4 answers

How can I put margins in an image?

I have a binary image of 18x18 pixels and I want to put margins around this image with the purpose of obtaining an image 20x20 pixels. The image is binary and it can be represented by a matrix of 1s and 0s. The 0 pixels are in black colour and the…
user5380136
3
votes
1 answer

OpenCV Save a Mat as Binary (1-bit depth) TIFF

Suppose we have a Mat after applying the OpenCv's Imgproc.adaptiveThreshold: Mat srcImage = ...; Mat binaryImage = new Mat(); Imgproc.adaptiveThreshold(srcImage, binaryImage, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, …
Alexander Abakumov
  • 13,617
  • 16
  • 88
  • 129
2
votes
2 answers

Extract most central area in a Binary Image

I am processing binary images, and was previously using this code to find the largest area in the binary image: # Use the hue value to convert to binary thresh = 20 thresh, thresh_img = cv2.threshold(h, thresh, 255,…
2
votes
0 answers

Separate correctly blobs in image

I'm writing code that should detect Hebrew letters. This is my initial image: The 2 letters (ע and נ) are connected, and thus I can't identify them correctly. So I use dilation to separate them: ker = np.ones((2, 2), np.uint8) dilated_img =…
2
votes
1 answer

How to remove small regions connected by a few pixels from the main region of a binary image?

I have the following image which I have obtained after a segmentation process. Which function or algorithm should I use to remove the small regions (marked by red circles) that are connected to the main segmented region by a very small number of…
2
votes
1 answer

How to read the file and convert it to a binary image in Python

I am new to Python, I want to read a image like jpg,png. and convert it to binary image. Here is my work: from PIL import Image import numpy def main( ): name= 'b.jpg' img= Image.open (name); for pixel in iter(img.getdata()): …
bufferoverflow
  • 81
  • 1
  • 1
  • 4
2
votes
0 answers

Conditional mask considering neighborhood in Python

I want to binarize an 2D numpy array by using a gray level condition, but considering a 4 connectivity neighborhood. Guess the mask could be something like 0 1 0 1 1 1 0 1 0 In other words, I don't want isolated pixels to be extracted from the…
2
votes
0 answers

Remove connected objects from binary image

I have a binary skeletonized image with many blobs in the form of vertical lines, most of them are straight and some of them are intersecting each other. I want to remove all those blobs which are intersecting each other. Is there any way? I have…
SAIP
  • 99
  • 7
2
votes
1 answer

OpenCV--how to get better hand contour from low quality gray image?

I need to get contour from hand image, usually I process image with 4 steps: get raw RGB gray image from 3 channels to 1 channel: cvtColor(sourceGrayImage, sourceGrayImage, COLOR_BGR2GRAY); use Gaussian blur to filter gray…
Alfred
  • 21
  • 4
1
2 3
8 9