Skip to main content

All Questions

1vote
0answers
99views

Why is dividing a uint8 numpy array by a float32 faster than explicit type conversion?

I am working with some image data so the images are represented as numpy arrays with shape (1404, 1404, 3). The image is of type np.uint8 (it has RGB values from 0 to 255) I am wondering about the ...
1vote
2answers
486views

Show a 2d numpy array where contents are tuples as an image

I have a 2d (M * N) numpy array, where each cell contains a tuple of length 3. The tuple contains R, G, and B values for each pixel, e.g. A[0,0] = (0, 255, 0) Is there a way to show this array as an ...
0votes
1answer
402views

How to convert from cv2 findContours to np array when there are multiple arrays in the contours?

I have a picture of a simple black and white mandala. I'm using Python and cv2 and numpy. My goal is to get the contour as X, Y coordinates and save them in a gcode file. The problem is that I get as ...
-1votes
1answer
55views

Sum of postive intergers in a list is negative

I am trying to calculate intensities in different regions in a image(taken in 16-bit). I have created binary masks first of the different regions, then using the masking I calculate the intensities. ...
1vote
0answers
39views

I can't use coordinate values in list for hough line function

I want to use the Hough line function. When I look at my list, yes, I found the coordinate values of the edges, but when I want to plot it in a for loop, I get an error. Here is the error message: ...
-2votes
1answer
69views

Can not rashape a numpy array

I have the following code, which should decrease the width of an image passed as a numpy array by one. Array seam has the column-indices of the pixels to be deleted from corresponding row. To do the ...
0votes
1answer
186views

Image Convolution with callback function in python

I want to loop over the pixels of a binary image in python and set the value of a pixel depending on a surrounding neighborhood of pixels. Similar to convolution but I want create a method that sets ...
0votes
1answer
558views

how to truncate an array of uint8 rather than overflow, when adding a value? [duplicate]

I would like to implement a tool to adjust the brightness of a RGB image, which is simply a (N, M, 3)-shaped numpy array of dtype uint8. The algorithm is really simple, I'm just adding an integer in ...
0votes
0answers
60views

Import an image as a 2D array of RGB tuples rather than a 3D array of values [duplicate]

Is there a NumPy function or "way" to directly import an image as a 2D array of RGB 3-tuples instead of the usual 3D array of values? So far, I've arrived at this solution: from PIL import ...
0votes
0answers
444views

Error using OpenCV for Connected Components on numpy arrays

I'm trying to do a connected component analysis on an image using OpenCV in python. The images are in a '.czi' format so I am using aicsimageio to import the file into numpy array. However, I keep ...
0votes
1answer
364views

Why doesn't my blur matrix filter blur the photo, and why does it make it darker?

I am at a loss here, sorry if this question seems stupid. I have the following code that should return a blurred image of a cat: def convolve(image, kernel): #IMPLEMENT HERE image_copy=image.copy()...
0votes
1answer
302views

Get a portion of the original image and put it onto another image using numpy array

I have two pictures, 1 of a minion with green background and one of a cat. I want to get the minion from the first and image and put it in front of the cat in the 2nd page. I have written the code for ...
0votes
0answers
407views

Change resolution of a image in ndarray format without changing dimensions in pixel

In my specific case I have volumes in nifti format (CT images), which I convert to ndarray format in order to do a series of preprocessing operations. Among these I should decrease the resolution of ...
2votes
1answer
92views

How can I simplify the following code so it runs faster?

I have a three-dimensional array containing many 2D images (frames). I want to remove the background by considering a threshold for each pixel value and copy new elements in a new 3D array. I wrote ...
0votes
1answer
62views

Finding a multi-value submatrix with wildcards

I have a matrix with these values (if it helps, this an rgb image): mat = np.array([ [[0, 0, 0], [123, 0, 255], [0, 0, 0]], [[0, 0, 0], [123, 0, 255], [45, 0, 54]], [[0, 0, 0], [100, 0, ...

153050per page
close