scikit-image

How to de-skew a text image also retrieve the new bounding box of that image?

微笑、不失礼 提交于 2020-02-28 09:30:26
问题 Here's a receipt image that I've got and I've plotted it using matplotlib and If you see the image the text in it is not straight. How can I de-skew and fix it? from skimage import io import cv2 # x1, y1, x2, y2, x3, y3, x4, y4 bbox_coords = [[20, 68], [336, 68], [336, 100], [20, 100]] image = io.imread('https://i.ibb.co/3WCsVBc/test.jpg') gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) fig, ax = plt.subplots(figsize=(20, 20)) ax.imshow(gray, cmap='Greys_r') # for plotting bounding box

How do I make a mask from one image and then transfer it to another?

☆樱花仙子☆ 提交于 2020-01-15 04:14:08
问题 I'm trying to solve a homework problem where I need to get a mask from one image (DAPI) and then apply it to the second image (NPM1) of cells (they are the same cells in the exact same location) I've been running in circles for about 4 hours trying to get the mask applied using a True/False approach but it doesn't seem to work. I've tried and failed with a bunch of other approaches but just pasting the one that I thought would most likely work (I'm super new to coding) %matplotlib inline

Uniform LBP with scikit-image local_binary_pattern function

╄→尐↘猪︶ㄣ 提交于 2020-01-13 09:39:12
问题 I'm using the local_binary_pattern from skimage.feature with uniform mode like this: >>> from skimage.feature import local_binary_pattern >>> lbp_image=local_binary_pattern(some_grayscale_image,8,2,method='uniform') >>> histogram=scipy.stats.itemfreq(lbp_image) >>> print histogram [[ 0.00000000e+00 1.57210000e+04] [ 1.00000000e+00 1.86520000e+04] [ 2.00000000e+00 2.38530000e+04] [ 3.00000000e+00 3.23200000e+04] [ 4.00000000e+00 3.93960000e+04] [ 5.00000000e+00 3.13570000e+04] [ 6.00000000e+00

Compare the LBP in python

自闭症网瘾萝莉.ら 提交于 2020-01-13 02:53:26
问题 I generated a texture image like this I have to compare two textures. I have used histogram comparison method. image_file = 'output_ori.png' img_bgr = cv2.imread(image_file) height, width, channel = img_bgr.shape hist_lbp = cv2.calcHist([img_bgr], [0], None, [256], [0, 256]) print("second started") image_fileNew = 'output_scan.png' img_bgr_new = cv2.imread(image_fileNew) height_new, width_new, channel_new = img_bgr_new.shape print("second lbp") hist_lbp_new = cv2.calcHist([img_bgr_new], [0],

Compare the LBP in python

天大地大妈咪最大 提交于 2020-01-13 02:53:06
问题 I generated a texture image like this I have to compare two textures. I have used histogram comparison method. image_file = 'output_ori.png' img_bgr = cv2.imread(image_file) height, width, channel = img_bgr.shape hist_lbp = cv2.calcHist([img_bgr], [0], None, [256], [0, 256]) print("second started") image_fileNew = 'output_scan.png' img_bgr_new = cv2.imread(image_fileNew) height_new, width_new, channel_new = img_bgr_new.shape print("second lbp") hist_lbp_new = cv2.calcHist([img_bgr_new], [0],

skimage: Why does rgb2gray from skimage.color result in a colored image?

て烟熏妆下的殇ゞ 提交于 2020-01-10 11:53:29
问题 When I tried to convert the image to gray scale using: from skimage.io import imread from skimage.color import rgb2gray mountain_r = rgb2gray(imread(os.getcwd() + '/mountain.jpg')) #Plot import matplotlib.pyplot as plt plt.figure(0) plt.imshow(mountain_r) plt.show() I got a weird colored image instead of a gray scale. Manually implementing the function also gives me the same result. The custom function is: def rgb2grey(rgb): if len(rgb.shape) is 3: return np.dot(rgb[...,:3], [0.299, 0.587, 0

How to extract rectangles of varying edge intensity from images?

拈花ヽ惹草 提交于 2020-01-05 07:20:13
问题 I am trying to extract the account number from an image of a cheque. The logic that I have is that, I am trying to find the rectangle that contains the account number, slice the bounding rectangle and then feed the slice into an OCR to get the text out of it. The problem I am facing is when the rectangle is not very prominent and light colour, I am not able to get the rectangle contour since the edges are not connected totally. How to overcome this? Things I tried, but did not work are I

Create buffer zone within a Numpy array

只愿长相守 提交于 2020-01-04 16:58:53
问题 I have a binary image as follows: data = np.array([[0, 0 , 0 , 0 , 0 , 0 , 0 , 0], [0, 0 , 0 , 0 , 0 , 0 , 0 , 0], [0, 0 , 1 , 1 , 1 , 1 , 0 , 0], [0, 0 , 1 , 1 , 1 , 1 , 0 , 0], [0, 0 , 1 , 1 , 1 , 1 , 0 , 0], [0, 0 , 0 , 0 , 0 , 0 , 0 , 0], [0, 0 , 0 , 0 , 0 , 0 , 0 , 0]]) For pixels having 1s values, I want to make buffer zone of two pixels with value 1s surrounded in every four directions. The expected result would be: result=np.array([[1, 1 , 1 , 1 , 1 , 1 , 1 , 1], [1, 1 , 1 , 1 , 1 , 1

Create buffer zone within a Numpy array

爷,独闯天下 提交于 2020-01-04 16:58:07
问题 I have a binary image as follows: data = np.array([[0, 0 , 0 , 0 , 0 , 0 , 0 , 0], [0, 0 , 0 , 0 , 0 , 0 , 0 , 0], [0, 0 , 1 , 1 , 1 , 1 , 0 , 0], [0, 0 , 1 , 1 , 1 , 1 , 0 , 0], [0, 0 , 1 , 1 , 1 , 1 , 0 , 0], [0, 0 , 0 , 0 , 0 , 0 , 0 , 0], [0, 0 , 0 , 0 , 0 , 0 , 0 , 0]]) For pixels having 1s values, I want to make buffer zone of two pixels with value 1s surrounded in every four directions. The expected result would be: result=np.array([[1, 1 , 1 , 1 , 1 , 1 , 1 , 1], [1, 1 , 1 , 1 , 1 , 1

Image processing - fill in hollow circles

六眼飞鱼酱① 提交于 2020-01-04 15:27:46
问题 I have a binary black and white images that looks like this I want to fill in those white circles to be solid white disks. How can I do this in Python , preferrably using skimage ? 回答1: Do a morphological closing (explanation) to fill those tiny gaps, to complete the circles. Then fill the resulting binary image. Code : from skimage import io from skimage.morphology import binary_closing, disk import scipy.ndimage as nd import matplotlib.pyplot as plt # Read image, binarize I = io.imread(