image-processing

Why do edge detection results look different for uint8 and float32?

Why do edge detection results look different for uint8 and float32? Question: I use OpenCV’s Sobel filter for edge detection. I was wondering why the output looks different when I run the 2 following lines. # uint8 output img_uint8 = cv2.Sobel(img_gray, cv2.CV_8U, dx=1, dy=0, ksize=5) # float32 output img_float32 = cv2.Sobel(img_gray, cv2.CV_32F, dx=1, dy=0, ksize=5) …

Total answers: 1

Find all disjoint subsets of a binray matrix in Pyhton

Find all disjoint subsets of a binray matrix in Pyhton Question: I have a binary matrix, and I want to find all disjoint subsets that exist in this matrix. To clarify the problem, the matrix is a collection of image masks, masks of irregular shapes, and each disjoint subset of 1s representing a separate mask. …

Total answers: 1

How to enlarge object area on mask

How to enlarge object area on mask Question: I am working on a computer vision project and I need to extract the object from the image with preprocessing so I can eliminate noise and redundant parts in the image. What I am trying to do is multiplying image by a mask that is thresholded image …

Total answers: 1

How can I remove small pixel clusters from a transparent png using python

How can I remove small pixel clusters from a transparent png using python Question: I am trying to remove random pixel clusters noise from a transparent png using python. I have used eroding and then dilating like this import cv2 import numpy as np img = cv2.imread(‘test1.png’) blurred_img = cv2.medianBlur(img, 1) kernel = np.ones((2,2),np.uint8) erosion …

Total answers: 1

FileNotFoundError: [Errno 2] No such file or directory for Image Dataset one-hot encoded

FileNotFoundError: [Errno 2] No such file or directory for Image Dataset one-hot encoded Question: I tried to one-hot encoded using to_categorical() in my image dataset but I failed because of FileNotFoundError: [Errno 2] No such file or directory error and the code is given below, import os import numpy as np from PIL import Image …

Total answers: 1

How do I create a 16-bit grayscale image from my array dataset

How do I create a 16-bit grayscale image from my array dataset Question: I want to convert a height map from NASA database into an image file. There is already a bit about this on the net and that helped me to read the file into an array and it looks like this: data = …

Total answers: 1

How can I add Rayleigh noise to an image in python?

How can I add Rayleigh noise to an image in python? Question: I am doing the following image processing using cv2: import numpy as np import cv2 image = cv2.imread(‘./tomatoes.png’,cv2.IMREAD_GRAYSCALE) noise_std = 0.1 noise = np.random.rayleigh(noise_std, image.shape) noisy_image = image + noise cv2.imwrite(‘noisy_image.jpg’, noisy_image) cv2.imshow(‘Noisy Image’, noisy_image) cv2.waitKey(0) The problem is: I only receive a …

Total answers: 1

Calculating probability distribution of an image?

Calculating probability distribution of an image? Question: I want to find the probability distribution of two images so I can calculate KL Divergence. I’m trying to figure out what probability distribution means in this sense. I’ve converted my images to grayscale, flattened them to a 1d array and plotted them as a histogram with bins …

Total answers: 1

How can i convert images into grayscale?

How can i convert images into grayscale? Question: I have 1000 of images. Now I like to convert those images into grayscale? import tensorflow as tf from tensorflow.keras.utils import img_to_array #df[‘image_name’] = df[‘image_name’].apply(str) df_image = [] for i in tqdm(range(df.shape[0])): img = image.load_img(‘/content/drive/MyDrive/Predict DF from Image of Chemical Structure/2D image/’+df[‘image_name’][i]+’.png’,target_size=(100,100,3)) img = image.img_to_array(img) img = …

Total answers: 1