image alignment with set points-python - python

I've been looking for a way to align at least two images in Python.
There are some very nice scripts out there, but I'd like a script that accepts the coordinates of a point in one image and use these coordinates to align the second(or more) image.
I'v been reading about phase correlation algorithms but I'd appreciate some help on how to use the coordinates of a user defined point.
Thank you!

Related

edge detection of an image and saving cells of a grid

picture example
I have recently started learning Python with Spyder IDE and I'm a bit lost so I ask for advice.
The thing is that I need to program an algorithm that, given a random image representing a board with black spots in it (in the picture I upload It is a 4x5 board) so It recognizes the edges properly and draw a AxB grid on it. I also need to save each cell separately so as to work with them.
I know that open CV treat images and I have even tried auto_canny but I don't really know how to solve this problem. Can anybody give me some indications please?
as I understand from your question you need to have as an output the grid of the matrix in your picture (eg. 4x3) and each cell as separate image.
This is the way I would approach this problem:
Use canny + corner detection to get the intersection of the lines
With the coordinates of the corners you can form your regions of interest, crop each individually and save it as a new image
For the grid you can check the X's and the Y's of the coordinates, for example you will have something like: ((50, 30), (50,35),(50,40)) and from this you can tell that there are 3 points on the horizontal axis. I would encourage you to set a error margin as the points might not be all on the same coordinate, but may not differ a lot.
Good luck!

Convert Latitude Longitude to IMG Pixel Values Python

I'm working on a project that involves reading colored data from an image (I'll attach somewhere). The input needs to be in longitude latitude. It is important that I find a way to convert these coordinates to pixels in the image. I have been contemplating this issue a lot and no great solutions are popping in mind. Unfortunately, the raw data used to construct the image is not released. Any ideas? :)Image I need to find color values for
Edit: A problem here is that these images curve the earth so the latitude lines are not parallel lines. They have a curve.
One way that might work depending on your image is to use something similar to http://www.lat-long.com/ ,using Google maps to find a point. You will have to scale the image from google maps and overlay it on top of your image, and get the pixel value. You should be able to request an image with the proper level of zoom. The good news is that, since your image is static, you can hardcode the zoom level.

How to generate bounding box data from heatmap data of an image?

I have a group of images and some separate heatmap data which (imperfectly) explains where subject of the image is. The heatmap data is in a numpy array with shape (224,224,3). I would like to generate bounding box data from this heatmap data.
The heatmaps are not always perfect, So I guess I'm wondering if anyone can think of an intelligent way to do this.
Here are some examples of what happens when I apply the heatmap data to the image:
I found a solution to this in matlab, but I have no idea how to read this code! I am a python programmer, unfortunately.
https://github.com/metalbubble/CAM/tree/master/bboxgenerator
Anyone have any ideas about how to approach something like this?
I am not quite sure how the heatmap data of your project exactly looks like, but it seems to me that you can use something like Selective Search. You can also have a look on this interesting paper. Maybe you can use this approach on your dataset.
I'm attempting a similar method for automating the creation of bounding boxes (since, lets face it: creating boxes manually takes along time)
this other stackpost covers a similar idea:
EDIT: (i originally had put a link to the current stack post 🤦 - but here is the stack post i was referring to)
Generating bounding boxes from heatmap data
the problem at hand that i recognize is that heatmaps can be fragmented and a bit arbitrary. the solution that comes to mind initially is setting a threshold of the heat map. So in the case of the example heat map images - when applying a bounding box cover all regions that are yellow/orange/red than say green/blue.
It depends on how many bounding boxes you need. You can set a threshold and have multiple bounding boxes for each of the highly activated regions, or try connecting the regions (by a morphological operation maybe) and calculate a single bounding box for connected activated pixels.

how to count point which based on projection of a set of coordinates

I have some data about a set of coordinates, like {(x=1, y=2), (x=3, y=4), ...}. I projected these coordinates on the picture. Then I would like to count these point in different position. My idea is below
First, separate the picture from several pixel parts based on 10 pixels.
Second, count the point inside the pixel box.
I am new in these area, and I use python a lot. I think this may be computer graphic problem.
I am not asking for a code solution. I just want to know which libraries or approaches that are related.
Anyone could give me a hint would be highly appreciated. Thanks.
Sure, your approach seems fine. You simply want to count the number of pixels in different image regions that you placed, correct?
I answered a question recently (with Python) that was giving an indication if there was a black pixel inside an image region. It could be easily modified to count pixels instead of simply finding one. Check it out here and modify your question or post a new one if you have code problems working it out.

minMaxLoc function - How to access the variables?

I have a question, some of you might find it a stupid one but I am stuck on a thing, hopefully you can help me.
I am using the following function in order to find the location of the brightest and the darkest pixel of an image:
darkest,brightest,dark_loc,bright_loc=cv2.minMaxLoc(img)
Now I need the values from dark_loc and bright_loc (both on the x and y axis in difference variables a and b) in order to calculate the distance from the centre of the image. I need those values in order to track a laser beam on a screen. Could you please help me to extract the values?
Thanks in advance!
Regards,
Vassil
P.S.: I am not sure if it's of any relevance but I am doing this using OpenCV on an RPi 2B.

Categories