I want to make a contour image from a depth image,
1. Convert a depth image into an image consisting of small blocks of 4 * 4 pixels
Find the maximum and minimum values of the depth values of 2, 4 * 4 pixels
3. If the obtained difference is larger than the threshold value, it is determined that all the pixels in the small block are contour lines.
I would like to guide the image by the procedure.
I was able to read the image and paint 4 * 4 pixels with the same color as one block to make a low-resolution image, but I'm not sure where to read the pixel value from there and decide the judgment.
The following program is the program used when seeking a low resolution image.
I would like to change this partly to create a contour image.
import numpy as np import matplotlib.pyplot as plt import cv2 from skimage import io img_orig = io.imread ('IMG_0072.jpeg') plt.imshow (img_orig) plt.show ()
def pool_max (img, ksize_h = 16, ksize_w = 16): _img = img.copy (). astype (np.float32) # padding h, w = img.shape [: 2] outer_h = h% ksize_h pad_top = outer_h // 2 pad_bottom = outer_h --pad_top outer_w = w% ksize_w pad_left = outer_w // 2 pad_right = outer_w --pad_left _img = np.pad (_img, [(pad_top, pad_bottom), (pad_left, pad_right), (0, 0)],'edge') out = np.zeros_like (_img) new_h, new_w = out.shape [: 2] c = 1 if len (out.shape) == 2 else out.shape  #filtering for iy in range (0, new_h, ksize_h): for ix in range (0, new_w, ksize_w): for ic in range (c): out [iy: iy + ksize_h, ix: ix + ksize_w, ic] = _img [iy: iy + ksize_h, ix: ix + ksize_w, ic] .max () out = out [pad_top: pad_top + h, pad_left: pad_left + w] return np.clip (out, 0, 255) .astype (np.uint8) img_pool = pool_max (img_orig) #pooling plt.figure (figsize = (12, 3)) plt.subplot (1, 2, 1) plt.title ('input') plt.imshow (img_orig) plt.subplot (1, 2, 2) plt.title ('answer') plt.imshow (img_pool) plt.show ()
Answer # 1
I'm currently filling a small block with .max (), and I thought that if you subtract .min () from .max (), the difference will come out and you can judge.
- how to save the image ocr result file in python
- python - image recognition using cnn keras multiple inputs
- python - about image deletion in django
- python - create a program to automatically take a screenshot of the kindle screen and save it
- python - tkinter photo image question
- python - tabelog scraping: i want to create a data frame for each store name, address, and evaluation score
- python - i want to create a function that finds the standard deviation sigma from x, y
- python contour detection¢roid calculation
- python - django image folder reasons to create static and madia folders separately
- python - i want to read an image and display it
- python - image recognition with keras
- python - i want to divide the read image into pixels and label them
- python - i want to display an image with pysimplegui, but an error occurs
- python - i want to convert a black and white image to an arbitrary color image
- python - error in image binarization using cv2adaptivethreshold function
- about image output of python
- python - image cannot be read by opencv
- python - image is not saved even though there is no opencv error
- python image display error beginner, thank you
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory