image-processing

How to detect pits on smart card contact pins using diplib

How to detect pits on smart card contact pins using diplib Question: During the smart card manufacture process, a probe stucks could leave pits on contact pins. I try to use dip.tophat and dip.HysteresisThreshold to extract the pits, this works but found more local height outside or near the edge of the contact pins. How …

Total answers: 2

AttributeError: EagerTensor object has no attribute 'astype'

AttributeError: EagerTensor object has no attribute 'astype' Question: I am trying to do a GradCAM Heatmap in Google Colab like so: import tensorflow as tf from tensorflow.keras import backend as K from tf_keras_vis.activation_maximization import ActivationMaximization from tf_keras_vis.utils.callbacks import Print def model_modifier(m): m.layers[-1].activation = tf.keras.activations.linear activation_maximization = ActivationMaximization(model, model_modifier) loss = lambda x: K.mean(x[:, 1]) activation …

Total answers: 1

Why is median blur not working? – OpenCV – Python

Why is median blur not working? – OpenCV – Python Question: I have a function to add gaussian noise to an image read by OpenCV with imread that returns an image (matrix). I am trying to use median blur on that image but terminal returns this error: median = cv2.medianBlur(image, 5) ^^^^^^^^^^^^^^^^^^^^^^^^ cv2.error: OpenCV(4.7.0) D:/a/opencv-python/opencv-python/opencv/modules/imgproc/src/median_blur.simd.hpp:870: …

Total answers: 1

How do you detect the largest set of parallel lines in an image?

How do you detect the largest set of parallel lines in an image? Question: I have images with multiple line in them and I’m looking to detect the largest set of lines which are (approximately) parallel using Python and OpenCV. For example give: The green lines are the best set: Asked By: nickponline || Source …

Total answers: 1

Find "noisy" lines in a image with cv2 in python

Find "noisy" lines in a image with cv2 in python Question: I have the following image: What is the best way to find the brown lines? The output image should kind of look like this: I have tried to just filter out the brown color, but I couldn’t find a good color range. Asked By: …

Total answers: 3

Find countors on a dark background

Find countours on a dark background Question: Suppose, I have a dark image on a white background. For example, the image below: With the code below, I can easily extract its countors import imutils import cv2 image = cv2.imread("image.jpg") image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) image = imutils.resize(image, width = 64) thresh = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, …

Total answers: 2

Why do image size differ when vertical vs horizontal?

Why do image size differ when vertical vs horizontal? Question: Tried to create a random image with PIL as per the example: import numpy from PIL import image a = numpy.random.rand(48,84) img = Image.fromarray(a.astype(‘uint8’)).convert(‘1’) print(len(img.tobytes())) This particular code will output 528. Wen we flip the numbers of the numpy array: a = numpy.random.rand(84,48) The output …

Total answers: 1

OpenCV functions specifically built for uint8 datatype

OpenCV functions specifically built for uint8 datatype Question: I am using the cv2.calcOpticalFlowFarneback() function in Python to calculate the optical flow between two images and find the translation vector between the two displaced images. The images which I’m using have been generated by an atomic force microscope, which gives resolutions for each pixel value significantly …

Total answers: 1

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