Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
44 views

Does the Intensity of color in OpenCV image matter?

Here is a simple code which puts a text value onto a black frame and displays it: frame = np.zeros((50,200,3)) org=(0,45) font=cv2.FONT_HERSHEY_SIMPLEX fontScale=1 fontColor=(1,0,0) ##rgb out_img =...
Allohvk's user avatar
  • 1,286
1 vote
2 answers
173 views

How to save the Fourier transform of an image such that I can modify it in an image editor?

I have a noisy image with a particular pattern and I want to remove the pattern. I save the FFT magnitude to a tiff image and the phases to a np.array text file. I have this python code that computes ...
Cristian Cutite's user avatar
1 vote
1 answer
3k views

How to convert a matplotlib figure to a cv2 image?

I would like to know how convert a matplotlib figure to a cv2 image, this is my python3 code: import cv2 import matplotlib.pyplot as plt # Generating matplotlib figure and save it as a png image ...
Nau's user avatar
  • 479
0 votes
1 answer
176 views

calculate the RMS intensity image with opencv

I would like to calculate the intensity of I(x,y)/Io(x,y). First, I read my images using rawpy because I have .nef files (Nikon raw). Then I use opencv to transform my images into grayscale and I ...
Suntory's user avatar
  • 351
3 votes
2 answers
448 views

OpenCV pointPolygonTest() not working correctly

I want to split an image in 6 equal areas (as seen in the picture) and then I want to know to which area a point belongs to. I'm using pointPolygonTest() to check whether a point is inside a contour ...
cogno.luis's user avatar
0 votes
0 answers
67 views

Not able to see black and white image after threshold application

I am working on a project for detecting lines using threshold values in HLS image format. I wrote the following code for it. It is not giving any errors but the output I am getting is just a black ...
programmer_04_03's user avatar
0 votes
1 answer
484 views

How can visualize 5 channel of image one by one?

I have a numpy array which dimension is (5, 3024, 4032) and data type float64. It is a 5 channel image and my question is: how can I visualize each channel one by one? My input: data_gt = np.load('...
Asifuzzaman Jishan's user avatar
-1 votes
1 answer
54 views

Make img's close range of RGB/HSV in particular value

share pic link: https://i.sstatic.net/hV9xH.jpg If I have black gradient img , we know the RGB is (0 ~ 255) or HSV is (0 ~ 255) How can I make close color range color together such as ( 0 ~ 80), ( ...
user avatar
0 votes
3 answers
156 views

Unclear difference in displaying the same image by opencv and matplotlib [with example code & exported .npy file]

In continue to my previous question (that still not answered here) Here is a simple code with some unsuccessful attempts and exported image.npy file that illustrates the problem: ''' conda install ...
Daniel Agam's user avatar
3 votes
0 answers
1k views

ImportError: cannot import name 'get_versions' from 'matplotlib._version'

When doing my imports: import cv2 from matplotlib import pyplot as plt import numpy as np import opencv_wrapper as cvw I get: ImportError Traceback (most recent call ...
duarte harris's user avatar
4 votes
1 answer
1k views

Calculating divergence and curl from optical flow and plotting it

I'm using flow = cv2.calcOpticalFlowFarneback() to calculate optical flow in a video and it gives me a numpy array with a shape of (height, width, 2) that contains the Fx and Fy values for each pixel (...
Bence Nagy's user avatar
2 votes
2 answers
1k views

Quantify longest axis and width of irregular shapes within a single image

Original question I have about 80-100 images such as (A). Each image is composed of shapes that were filled with black color after marking the outline in ImageJ. I need to extract each individual ...
Anurag N. Sharma's user avatar
0 votes
0 answers
1k views

Problems with importing some modules (here numpy) (ModuleNotFoundError: No module named 'numpy.core._multiarray_umath')

i would like to use opencv and tried to install the needed modules. i need to install everything manually per donwload and then pip or install. I am using Python 3.10.1 and Pip 21.2.4. My project is ...
Chorum's user avatar
  • 63
0 votes
0 answers
389 views

heatmap generated from numpy array gives inaccurate results

I am trying to generate a heatmap using bounding boxes coordinates to display the area where the detected object went to inside a room. To do that, I created a numpy array and used the coordinates to ...
Wazaki's user avatar
  • 899
1 vote
2 answers
425 views

Keep the original shape of the array as the image

I have some data. I visualize and then save it as image. import cv2 import numpy as np import matplotlib.pyplot as plt data = np.array([ [1,2,0,1], [0,1,2,1], [0,0,2,1]]) fig, ax = plt.subplots() ax....
voldr's user avatar
  • 392
0 votes
1 answer
707 views

Intersection area between a numpy array and a shapely polygon

I would like to calculate an area of the intersection of a shapely polygon, and a mask (numpy.array): plt.plot(*building.exterior.xy, color='brown', linewidth=4) plt.plot(*parcelle.exterior.xy, color='...
chambeeee's user avatar
-3 votes
1 answer
188 views

Colour intensity is changing when stacking numpy image arrays

I am loading an image from here, which is saved as .nii.gz. The image opens fine (with a dimension of (497x497)), and when displayed using matplotlib, it shows with correct intensities, as shown below:...
Jimut123's user avatar
  • 506
1 vote
1 answer
627 views

Extract the values from graph

I want to extract data from plot. Original plot: But I can't obtain original values, in some places extracted line (green) above original data (black line), in some places it is below. I assume I ...
user avatar
1 vote
1 answer
563 views

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() in plt.show() while plotting frame

I am trying to capture a video frame and then plot it using plt.imshow() but i am receiving this error. vs = cv2.VideoCapture('../input/hard-hat-dataset/short_clip.mp`enter code here`4') (grabbed, img)...
Manickavela Arumugam's user avatar
0 votes
0 answers
87 views

Change cv2.merge on matplotlib/numpy library command

I would like to change my code line "cv2.merge" to command from matplotlib/numpy library. This is my only line in code from cv2 and I don't know how to get rid of it. dataStretched have max ...
Gerard's user avatar
  • 117
1 vote
1 answer
530 views

Recording a video from images and the respective annotation files

I have images stored in the another format in a folder. In a separate folder, I have text files that contain the coordinates of the rectangles which are supposed to be drawn over the image. I use the ...
duddal's user avatar
  • 19
1 vote
1 answer
1k views

check if coordinates are overlapping using numpy, matplotlib

I need to check whether a square is overlapping with a defined polygon Yes, it can be easily done using shapely as below from shapely.geometry.polygon import Polygon from shapely.geometry import box ...
ShivAA's user avatar
  • 131
0 votes
1 answer
851 views

OpenCV - Is there a way to detect objects of a specific color only in certain areas of an image using masking?

I am currently implementing something in OpenCV in which I want to detect objects of a specific color in certain areas. I know in order to pick up certain areas I can use adaptive threshold, however ...
Ammu's user avatar
  • 29
1 vote
0 answers
168 views

Python3 cv2 and matplotlib import cause error

It seems when I try and use matplotlib and cv2 I get a weird QT error. I don't know what's causing it, here is how it looks: QObject::moveToThread: Current thread (0x560dde045c50) is not the object's ...
Yiannis128's user avatar
2 votes
1 answer
121 views

Converting pixels colour creates noise

just a quick question: I am loading a black and white image and then replacing the black and/or white pixels with other colors. The problem is when I visualize the edited image there are some black ...
Misanthropichen's user avatar
0 votes
1 answer
5k views

How to read images from our system folder to jupyter notebook python file

I have nine pictures inside a folder . I have to just read all the images in python for making a opencv model . I want to read the all images at the same time in my .py notebook for do operations on ...
Saurav Mishra's user avatar
0 votes
1 answer
385 views

Plotting mean of n 2-D arrays

I'm trying to calculate the mean of histograms of several images from a folder and visualize it. Here is the approach I'm trying. I would calculate the histogram of each image with open cv, cv2....
Vishal Pallikonda's user avatar
-3 votes
2 answers
354 views

Conversion of numpy array to image [closed]

The array is a two-dimensional array populated with zeros and ones. How can I convert this array to a grayscale image such that there is a dot representing one in the array and an empty space where ...
ABHAY MUDGAL's user avatar
0 votes
1 answer
4k views

TypeError: Expected Ptr<cv::UMat> for argument '%s'

I have this error that I have not been able to solve on my own. Can you tell me how to solve it please? The problem is in this function: import numpy as np import cv2 import matplotlib.pyplot as plt ...
zouaoui mahdia's user avatar
0 votes
2 answers
174 views

Numpy array of a png file is rotated in matplotlib.pyplot

I'm trying to scatter all white pixels of this gradient image in matplotlib.pyplot: import numpy as np from PIL import Image import cv2 from matplotlib import pyplot img = Image.open( "/root/...
LisaD's user avatar
  • 1
0 votes
1 answer
5k views

How to draw a Heatmap in a image using the coordinates in Python OpenCV?

I've a huge list of Coordinates(x,y) of people walking in the streets and I like to design a heatmap using those Coordinates(x,y), i.e., it should look something like this. I want much hotter spot for ...
Kailash Viswanathan's user avatar
10 votes
7 answers
15k views

Unable to send plot to http://127.0.0.1:63342

I am facing an error ie to send plot to a particular IP address using python, numpy and matplotlob. I am attaching snippet which I have tried till now. Python import numpy as np import cv2 ...
hosein's user avatar
  • 137
2 votes
1 answer
2k views

How to plot frame per seconds (fps) over time using matplotlib when processing a video?

the below code calculates the number of processed frames per second for a video and display it on the output processed frame using opencv: import cv2 as cv import numpy as np from collections import ...
Khaled's user avatar
  • 563
1 vote
1 answer
1k views

Find point coordinates on image

I've created random points and added a list these points double. Then I've drawn graphic and save as a image. I'm able to draw a line from one point to another point with this code : cv2.line(img=...
Atakan ADA's user avatar
0 votes
1 answer
226 views

How to plot training data and training target for SVC

I'm trying to visualize my data, by plotting it, after loading images and extracting its keypoints. However, when i try to scatter it, before plotting, i get the error my x and y values should be the ...
user avatar
-1 votes
1 answer
63 views

matplotlib and opencv typerror imagedata cannot be converted to float

there i am getting an error TypeError: Image data of dtype object cannot be converted to float i can't figure out what the solution is my code is import numpy as np import cv2 import matplotlib....
Neetesshhr's user avatar
2 votes
0 answers
50 views

How can I change the values of all the clusters obtained in an image to a new range that represents different levels of color intensity?

I'm doing some image analysis of samples of pseudomona. I'm using k-means clustering to obtain different levels of presence of the bacteria along the sample, as it changes tonality as it increases its ...
Jose Zapana's user avatar
0 votes
1 answer
286 views

Finding circle function and center in Python

I have a data set (512 X 512), which is a 2D array. This is the figure I plot based on this data set. Data looks like this: [[239 247 214 ... 466 511 415] [257 283 254 ... 460 474 474] [219 251 ...
Joanne's user avatar
  • 503
4 votes
1 answer
17k views

Saving 16-bit image in opencv with cmap (cv::ColorMap only supports source images of type CV_8UC1 or CV_8UC3 in function 'operator()')

I'm trying to save/show a 16-bit numpy array (as image) in opencv with cmap, it doesn't work. On the other hand, it works smoothly in matplotlib. My deep learning model gives a numpy array arr (<...
Harshit Kumar's user avatar
1 vote
1 answer
2k views

Gradient orientation with arctan2 results in flipped angles

I want to use plt.quiver to display arrows of the gradient of an array in the correct angle. import numpy as np import matplotlib.pyplot as plt test_array = np.array([[ 0., 0., 0., 0., ...
greedsin's user avatar
  • 1,272
1 vote
2 answers
904 views

updated:IndexError: index 0 is out of bounds for axis 0 with size 0?

I have a questions about the following codes: I want to return 2 values in this function, one is orig_image which is fine, the other one is the cx,cx is the x-coordinate of the center of the biggest ...
Thanatos Tod's user avatar
1 vote
2 answers
1k views

UnboundLocalError: local variable 'x1' referenced before assignment

import numpy as np from PIL import ImageGrab import cv2 import time import pyautogui import matplotlib.pyplot as plt def make_coords(img,line_param): slope,intercept=line_param y1 = img....
Thanatos Tod's user avatar
0 votes
1 answer
3k views

How to resize and translate a masked image over a background OpenCV and Python

By doing a bit of my own googling and following this tutorial I have created the python script below. It finds the most dominant (common) color in an image and replaces it with another "background" ...
coder's user avatar
  • 411
2 votes
1 answer
612 views

Car plate recognition from video using python

enter image description hereI am running this code but it has given an error which I am trying to solve. The given code is of car plate recognition from video written in python. The given error:- ...
Prajwal Dhage's user avatar
1 vote
2 answers
1k views

Opencv unexpected output for Sobel operator

I am extracting the white stripes from this image but intrigued to see the output of basic Sobel operator in 'Lab' image. Although I am excited to see the black stripes as desired outcome, I am unable ...
addcolor's user avatar
  • 503
0 votes
0 answers
115 views

know what are the pixel values ​through which a line passes over a grayscale image with the Bresenham line algorithm python

How to obtain pixel value of a gray scale image using the Bresenham line algorithm given a line at different angles as shown in this code fraction I hope and you can help me import cv2 import ...
luis's user avatar
  • 1
1 vote
1 answer
420 views

Inverted pixel coordinates of segmentation mask

The following is an image of a segmentation mask (it appears yellow). Overlaid onto this mask are the pixels/coordinates of the very same segmentation mask (appears blue). My question is: why are ...
DSH's user avatar
  • 1,139
4 votes
2 answers
4k views

Calculate and plot segmentation mask pixels

I have the following image: Below is a segmentation mask within this image: From the image above, I attempted to calculate the non-zero pixel coordinates. That is, I tried to get all of the pixels ...
DSH's user avatar
  • 1,139
3 votes
1 answer
5k views

How to convert my python code to run on GPU instead of CPU?

I was given a python code that takes in two images as input and uses the Gabor Filter to find the correlation of RGB of the two images and saves it in a csv file. So I need to execute the program ...
Soundeaf's user avatar
1 vote
1 answer
2k views

How to get numpy.zeros() and (numpy.ones() * 255) to produce a black and white image respectively?

I am new to Python + OpenCV, so this might be a basic question for most of you, as I couldn't find a good/ satisfactory solution for this online. So I am trying to create an Image by separately ...
RC0993's user avatar
  • 948