Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Getting the original pixel value in a thresholded RGB image

1.I have an RGB image and also depth values per pixel in a text file 2. I formed depth image and done thresholding 3. Now I want the original color of thee RGB image in the threshold part 4. What I feel is, I need to get the position of the black pixels and then create a full white pixel image and then will map the rgb values in the original image corresponding to the previously determined black pixel position into that white image. I have coded this far:

import cv2 import numpy as np

depth_image = np.loadtxt(fname = "D:/workspace/1.txt", delimiter=',', skiprows=0) print(depth_image.shape) rgb = cv2.imread("D:/workspace/1.jpg") print(rgb.shape) gray = cv2.cvtColor(rgb, cv2.COLOR_BGR2GRAY) out = np.zeros(depth_image.shape, np.double)

normalized = cv2.normalize(depth_image, out, 1.0, 0.0, cv2.NORM_MINMAX, dtype=cv2.CV_64F)

norm_image = cv2.normalize(depth_image, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

print(norm_image)

mask = norm_image < 0.1

sel = np.zeros_like(depth_image) colored = np.zeros_like(rgb) sel[mask] = depth_image[mask] sel_not = 255-sel

print(sel_not)

'''indices = np.where(sel_not == [10]) print (indices) coordinates = zip(indices[0], indices[1]) print (coordinates)'''

cv2.imshow('display',sel_not)

cv2.imshow('thresholded',colored)

cv2.waitKey(0)

Image used is: image description

Link to my depth information file

Getting the original pixel value in a thresholded RGB image

1.I have an RGB image and also depth values per pixel in a text file 2. I formed depth image and done thresholding 3. Now I want the original color of thee RGB image in the threshold part 4. What I feel is, I need to get the position of the black pixels and then create a full white pixel image and then will map the rgb values in the original image corresponding to the previously determined black pixel position into that white image. I have coded this far:

import cv2
import numpy as np

np depth_image = np.loadtxt(fname = "D:/workspace/1.txt", delimiter=',', skiprows=0) print(depth_image.shape) rgb = cv2.imread("D:/workspace/1.jpg") print(rgb.shape) gray = cv2.cvtColor(rgb, cv2.COLOR_BGR2GRAY) out = np.zeros(depth_image.shape, np.double)

normalized np.double) #normalized = cv2.normalize(depth_image, out, 1.0, 0.0, cv2.NORM_MINMAX, dtype=cv2.CV_64F)

dtype=cv2.CV_64F) norm_image = cv2.normalize(depth_image, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

print(norm_image)

dtype=cv2.CV_32F) #print(norm_image) mask = norm_image < 0.1

0.1 sel = np.zeros_like(depth_image) colored = np.zeros_like(rgb) sel[mask] = depth_image[mask] sel_not = 255-sel

print(sel_not)

255-sel #print(sel_not) '''indices = np.where(sel_not == [10]) print (indices) coordinates = zip(indices[0], indices[1]) print (coordinates)'''

cv2.imshow('display',sel_not)

cv2.imshow('thresholded',colored)

cv2.waitKey(0)

(coordinates)''' cv2.imshow('display',sel_not) #cv2.imshow('thresholded',colored) cv2.waitKey(0)

Image used is: image description

Link to my depth information file

Getting the original pixel value in a thresholded RGB image

1.I

  1. I have an RGB image and also depth depth values per pixel in a text file 2.
    1. I formed depth image and done thresholding 3. done thresholding
    2. Now I want the original color of of thee RGB image in the threshold part 4. part
    3. What I feel is, I need to get the the position of the black pixels and and then create a full white pixel image image and then will map the rgb values in in the original image corresponding to to the previously determined black black pixel position into that white image. white image.

I have coded this far:

import cv2
import numpy as np

depth_image = np.loadtxt(fname = "D:/workspace/1.txt", delimiter=',', skiprows=0)
print(depth_image.shape)
rgb = cv2.imread("D:/workspace/1.jpg")
print(rgb.shape)
gray =  cv2.cvtColor(rgb, cv2.COLOR_BGR2GRAY)
out = np.zeros(depth_image.shape, np.double)
#normalized = cv2.normalize(depth_image, out, 1.0, 0.0, cv2.NORM_MINMAX, dtype=cv2.CV_64F)
norm_image = cv2.normalize(depth_image, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)
#print(norm_image)
mask = norm_image < 0.1

sel = np.zeros_like(depth_image)
colored = np.zeros_like(rgb)
sel[mask] = depth_image[mask]
sel_not = 255-sel

#print(sel_not)
'''indices = np.where(sel_not == [10])
print (indices)
coordinates = zip(indices[0], indices[1])
print (coordinates)'''

cv2.imshow('display',sel_not)
#cv2.imshow('thresholded',colored)

cv2.waitKey(0)

Image used is: image description

Link to my depth information file

Getting the original pixel value in a thresholded RGB image

  1. I have an RGB image and also depth values per pixel in a text file
    1. I formed depth image and done thresholdingthresholding.
    2. Now I want the original color of thee RGB image in the threshold partthreshold part.
    3. What I feel is, I need to get the position of the black pixels and then create a full white pixel image and then will map the rgb values in the original image corresponding to the previously determined black pixel position into that white image.

I have coded this far:

import cv2
import numpy as np

depth_image = np.loadtxt(fname = "D:/workspace/1.txt", delimiter=',', skiprows=0)
print(depth_image.shape)
rgb = cv2.imread("D:/workspace/1.jpg")
print(rgb.shape)
gray =  cv2.cvtColor(rgb, cv2.COLOR_BGR2GRAY)
out = np.zeros(depth_image.shape, np.double)
#normalized = cv2.normalize(depth_image, out, 1.0, 0.0, cv2.NORM_MINMAX, dtype=cv2.CV_64F)
norm_image = cv2.normalize(depth_image, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)
#print(norm_image)
mask = norm_image < 0.1

sel = np.zeros_like(depth_image)
colored = np.zeros_like(rgb)
sel[mask] = depth_image[mask]
sel_not = 255-sel

#print(sel_not)
'''indices = np.where(sel_not == [10])
print (indices)
coordinates = zip(indices[0], indices[1])
print (coordinates)'''

cv2.imshow('display',sel_not)
#cv2.imshow('thresholded',colored)

cv2.waitKey(0)

Image used is: image description

Link to my depth information file

Getting the original pixel value in a thresholded RGB image

    • I have an RGB image and also depth values per pixel in a text file
        • I formed depth image and done thresholding.
        • Now I want the original color of thee RGB image in the threshold part.
        • What I feel is, I need to get the position of the black pixels and then create a full white pixel image and then will map the rgb values in the original image corresponding to the previously determined black pixel position into that white image.

I have coded this far:

import cv2
import numpy as np

depth_image = np.loadtxt(fname = "D:/workspace/1.txt", delimiter=',', skiprows=0)
print(depth_image.shape)
rgb = cv2.imread("D:/workspace/1.jpg")
print(rgb.shape)
gray =  cv2.cvtColor(rgb, cv2.COLOR_BGR2GRAY)
out = np.zeros(depth_image.shape, np.double)
#normalized = cv2.normalize(depth_image, out, 1.0, 0.0, cv2.NORM_MINMAX, dtype=cv2.CV_64F)
norm_image = cv2.normalize(depth_image, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)
#print(norm_image)
mask = norm_image < 0.1

sel = np.zeros_like(depth_image)
colored = np.zeros_like(rgb)
sel[mask] = depth_image[mask]
sel_not = 255-sel

#print(sel_not)
'''indices = np.where(sel_not == [10])
print (indices)
coordinates = zip(indices[0], indices[1])
print (coordinates)'''

cv2.imshow('display',sel_not)
#cv2.imshow('thresholded',colored)

cv2.waitKey(0)

Image used is: image description

Link to my depth information file