imagej status bar coordinate display - imagej

Does anyone know of a way to increase the number of digits displayed in ImageJ's status bar? This is normally not a problem if pixel coordinates are displayed, however once a scale is applied only two digits in the display is no longer sufficient depending on the scale factor.

ImageJ displays the coordinates of the cursor position with the help of ImagePlus#getLocationAsString(x,y), which in turn uses IJ.d2s(double n) to format the coordinates. The problem would be solved if IJ.d2s(double x, int significantDigits, int maxDigits) was used instead.
Feel free to write to the ImageJ mailing list, where Wayne Rasband (the developer of ImageJ 1.x) will likely pick it up and add the feature if he thinks it's appropriate.
As a workaround, you might want to press the alt key while moving the mouse, switching to pixel coordinates instead of calibrated coordinates in the status bar (see here).

Related

Delphi SetMapMode Inverts Text

I am working on a graphics application and have a number of objects with captions. To put the captions, I calculate an X, Y coordinate and call:
Canvas.TextOut(XText, YText, FCaption);
I decided to use a different mapping mode to make conversions from world space to device space simpler:
SetGraphicsMode(cnv.Handle, GM_ADVANCED);
SetMapMode(pbxMain.Canvas.Handle, MM_HIENGLISH);
and now my captions are printing upside down, but still left to right.
Any thoughts on how to remedy that?
One approach I had considered was setting the map mode back to the default for outputting text, which would require some conversions to get X, Y in the different mode. Is that a reasonable tactic? Is it "correct" to change map mode during paint routines...?
Although the y axis reversed when you set MM_HIENGLISH map mode, assuming a default previous value of MM_TEXT, it doesn't cause text to be output upside-down - it just effects where it's output.
You might want to check if you're calling SetWorldTransform which is a probable cause for the problem you observe - a faulty transformation. A negative value in eM22 of the transformation structure parameter causes a reflection in the y axis.
Regarding the last part, I don't see any problem switching map modes during a single drawing task, apart from it might complicate maintaining the code.

How do I "parse" image locations on a minimap with OpenCV (or other tool)?

I've been trying to work on a small hobby project that involves plotting players' positions from a game onto a heatmap, to see where the most active areas are at various points in time.
I'm a bit new to OpenCV and its tools, but I've managed to successfully run some text matching and extraction on the scoreboard and timers in the game, now trying to take the characters' positions from the in-game minimap.
It looks like this, which is the biggest resolution image I'm able to get with (about 185x185):
I'm trying to obtain the positions of only two things: the characters (big circles) and "wards", which are represented by these icons:
So given the assets to them, I thought that because there was too much "noise" in the source image, I'd try to subtract the background of in game minimap from its image, and then try to pattern match the original character and ward image with the resulting image together (which is meant to be the minimap, minus its background). But that didn't even get close to working as you can see:
> >
Even if that did work, I wouldn't be really sure how to handle cases where the icons are partially covering each other, or how I could obtain the positions of those little ward markers.
I'd really appreciate some help, as I've been searching the Internet and banging my head for a few days and haven't gotten anywhere. I've tried a bunch of difference techniques, read guides and articles, and tried a few GUI tools to experiment with but haven't gotten any closer to a method to work this out.
Please help me with what techniques I could or should be using instead, to get the locations of all the characters and wards.
I'm not an OpenCV user, but I can speak to some general problems.
First and foremost, you goofed in subtracting the background map. It appears that you did a straight, arithmetic subtraction of the map's RGB values. For instance, the blue-team icons in the lower-left corner are roughly #99FFFF, and you're subtracting the grayish background of maybe #D0D0FF. This leaves you with #002F00, a very dark green.
Also note that you're subtracting the original map, not the part that shows. Paths beyond view are shaded, but you appear to subtract the original value.
What you need to subtract is a masked background. Unfortunately, building that mask means that you have to find the icons. Masking won't work well at this stage.
Back to the subtraction: don't just blindly subtract. Rather, look for a match in hue. When you find a hue match, simply set that pixel to 0. You have two special cases to watch: icons on the background of their own colour, especially for the blue team. In this case, you need to define the region boundaries.
Start from a pixel that's an exact match to the original background. It won't be shaded, since all such problem pixels are in plain sight of an icon. Expand from that pixel so long as you have the exact match to the original background colour. That will give you the region you can blank out.
Your next problem is to identify icons. You should now have a map with only icons, many of which are fully revealed. Those are easy matches; identify and subtract them, one key icon at a time.
You now have a map of partial icons. Switch the match algorithm: a key icon is now a match to either the exact color, or to black (indicating it was previously covered). Iterate until you have no more matches.
This does still leave you with one problem: an icon that no longer has enough pixels showing to identify. These will be icons that were either entirely covered, or covered except for a small portion that is not unique, such as a few pixels of a red circular border.
For this, a general approach is to keep track of game progress to a small extent: from an earlier time, you know where the icon used to be. Track each icon as a software object. If other icons cover it, assume it's still there until you discover otherwise.
This will handle most cases. You'll still have some problems with minions or sensors that get shot out from underneath a legend's icon, but I trust that your heat map application is not so fragile as to take modelling damage from that situation. The legend will move soon enough, revealing the small item's death. A moving minion isn't covered by a legend for long; they don't move with the same intelligence.

Shape changing blobs

Ok, I'm not quite sure if this is something I can ask here so no need to shoot me down. Just tell me and i'll delete the question :)
I had this idea of making my own clock using a touch screen and program it myself.
While thinking about this I thought of all these different styles to show the current time.
Of all the styles I came up with there was one that I found the most fun which is a clock displaying the time Rorschach style. And no not just a random smudge and guess what time it is but more like Rorschach in watchmen.
He has a mask with inkblots that constantly change shape (really cool if you ask me).
So what I had in mind is inkblots that change shape according to the digit it represents.
When the time changes
12:49:58 -> 12:49:59 the 2nd second digit will transform from 8 -> 9.
So now back to the original problem:
Before attempting to get this type of clock running I want to try to give a blob a certain shape and make it transform into another shape.
I searched on google but without any luck so I was hoping there was someone here that could point me in the right direction for making a random blob and transform it into another shape in an animation.
For example:
Draw square -> animate to circle
Any tips and tricks are welcome :)
In order to get the most simpliest animation of digit transformation you could store all posible digits in one image (verticaly) and then only partially show that image in your component. So when you want to do transformation between one digit to another you simply slide the image up and down.
Now if you are using FireMonkey you could create a 3D viewport and inside it create a cylindical object onto which will you render your texture with digits. So now you only rotate the cilinder in order to show the corect digit.

Getiing BGR values by clicking a particular location of an image

Is there any method in Opencv using which when we click on a particular location of an image, it gives pixel location as well as B,G,R values. Thank You!
There is an answered similar post here.
Basically, you need to use setMouseCallback() and create your own callback function.
You can start from here to get the mouse location: http://www.wisegai.com/2012/10/29/using-mouse-callbacks-with-opencv-and-the-cvhighgui-module/
(I don't know in which coordinate system will be the click, i.e. of the window, of the image or of the screen)
And these might help for the second part.
How to read the screen pixels?
Screen Capture Specific Window
In term of coordinates it might have an impact the window frame, you'll have to try or google a little bit further.

cvHoughCircles() parameters in JavaCV?

I want to find circles in an image by using cvHoughCircles() .
But I confused about the fourth parameter, because when I use "1", the cvHoughCircles() does not find circles and when I use "2", the method work properly and detect all circles in the image.
Click Here to see the screenshot of my program for both cases.
I did the same operation on another image ,but this time changing the value of the fourth parameter from 1 to 2, didn't affect the result[cvHoughCircles() returned the same result for both cases( using 1 or 2 for the value of the fourth parameter)] .
Can anyone please tell me what value should be sued for the fourth parameter when working with different images?
Check out this link:
http://docs.opencv.org/modules/imgproc/doc/feature_detection.html
It lists the c/c++/python implementations for all the functions stating what each parameter does and i've always found that one of them is what javacv has been wrapping (in this case the c code). I was actually looking for this page when i came across your post so in case it happens again i can now follow my own link (awesome!). Now to answer your question as best I can.
The function looks like this:
CvSeq* cvHoughCircles(CvArr* image, void* circle_storage, int method, double dp, double min_dist, double param1=100, double param2=100, int min_radius=0, int max_radius=0 )
Where the site describes:
dp – Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has half as big width and height.
I am guessing (based on what i remember from class) that what this refers to is the pyramid scheme that is sometimes used in feature detection. Basically you average the pixels of an image to get a smaller image in order to find the locations of important features like corners or in this case circles which in the end is based on gradient information (hence the black and white or greyscale image that should be used).
Using dp=1 should be perfectly fine however, just make sure to call cvSmooth() on the image so the gradient vectors make a nice circle around the circle. If you know that there is a circle then you could keep smoothing and dilating (cvDilate) until the circle appears but then you may detect artifacts so the biggest circle should be of what's interest. In the end it depends on the situation you are putting the algorithms through.

Resources