How can JFreeChart print a scatter point directly on the x axis? - jfreechart

I try to make a scatter chart but the data point is not exactly at the (2,0) coordinate and only partly visible.
The image shows the generated output from JFreeChart:
http://i.stack.imgur.com/oGpZW.png
But it should be like this (made with GIMP):
http://i.stack.imgur.com/dqrnh.jpg
Does anybody know how to do it?
thanks for any help!!!

For anybody else, here is the solution, which didn't satisfy me completely but is acceptable:
http://i.stack.imgur.com/70TbB.png
The interesting lines of code to do so were:
plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
plot.getRangeAxis().setLowerMargin(0);

Related

How can I create a bitmap and draw it from an array of pixel colors in Xlib?

I tried following many questions and answers online on this topic but I was never able to draw the buffer to the screen in a form of an array. I found people were creating visuals but I have no idea if I need to do that, or I can just use DefaultVisual() to get it. I found on a post online that the format of the pixel data has to be BGRX. Is the X in BGRX supposed to be the current X coordinate, or will it just be ignored? How do I create the image properly? How do I draw it after that? Do I need a pixmap for this? I am sorry for asking so many questions but it is very difficult to combine information I found on the internet to actually understand how it works and how I can do it. Some use a depth of 0, some use a depth of 24, some supply 0 or NULL as the size in bytes of one line on the window. I get mixed information on this topic. (I might edit my post tomorrow and include the code that is not working.)
Any help would be appreciated!

calculate char's bbox with mupdf fz_stext_char_bbox

I occur an strange phenomenon using mupdf, which when I use fz_stext_char_bbox to get char's bbox, a lot of bbox are correct, but a little are wrong. I draw the bbox with red rectange on screen. Following picture is my capture:
these wrong bbox are always 0 on lefttop. In my code,
I get the fz_page by pageNo first.
then I use fz_new_stext_sheet, fz_new_stext_page and fz_new_stext_device create necessary parameter.
I use fz_run_page with current matrix and above parameters.
then I following the mupdf to use fz_stext_char_bbox in order to get the bbox.
I'm not sure it's necessory to list my code here, becaause it maybe too long. I seems my transform matrix is right but don't know why has wrong bbox. Do I forget something?

MS Chart - Chart type area- Backcolor issue

I'm using ms charts in winforms.
Till now i'm able to create this chart. Now the problem is i want that reddish paint to be inside the area, it is now starting to paint from 0, so looking reverse of what i actually want.
This is my first question to stackoverflow, it may not be constructive but i will give more info if you ask.
Apologies and thanks.
Some part of Code:
ChartArea.YAxis.Maximum = 0;
ChartArea.YAxis.Minimum = -100;
ChartArea.YAxis.IsStartedFromZero = False;
Series tempSeries = chartSSIDDetails.Series.FindByName("Series1");
tempSeries.Points.AddXY(0, -100); tempSeries.Points.AddXY(1, -20);
tempSeries.Points.AddXY(2, -20); tempSeries.Points.AddXY(3, -20);
tempSeries.Points.AddXY(4, -100);
There is nothing much than this. Please let me know anything else you need.
Graph is showing correct as per the code you have shown.
As the values for Y axis are negative, graph is projected downwards
(so you can see values are starting from 0 on Y-axis)
You will have to pass positive integers to Y-axis if you want to see it opposite way.
You can later customize label to show Y-axis values to negatives.

Plotting a locus in XY space using JFreeChart

I would like to plot the locus of a particle in two dimensional space.
My data is a sequence of X,Y coordinates and I would like to plot these.
Would appreciate any pointers to examples that show how to do this.
An example of a locus plot can be seen below:
Note: I'd like to show the path as a continuous line with arrows showing the direction of motion.
Thanks.
ChartFactory.createScatterPlot(), illustrated here, might be a good starting point.
FastScatterPlot, cited here and illustrated here, may be required for larger datasets.
Addendum: Looking at your revised question, I've not seen a renderer like that. You might look at a org.jfree.chart.annotations such as XYShapeAnnotation using a GeneralPath. These ArcTest variations may offer guidance. See also PointyThing.

Image-processing basics

I have to do some image processing but I don't know where to start. My problem is as follows :-
I have a 2D fiber image (attached with this post), in which the fiber edges are denoted by white color and the inside of the fiber is black. I want to choose any black pixel inside the fiber, and travel from it along the length of the fiber. This will involve comparing the contrast with the surrounding pixels and then travelling in the desired direction. My main aim is to find the length of the fiber
So can someone please tell me atleast where to start? I have made a rough algorithm in my mind on how to approach my problem but I don't know even which software/library to use.
Regards
Adi
EDIT1 - Instead of OpenCV, I started using MATLAB since I found it much easier. I applied the Hough Transform and then Houghpeaks function with max no. of peaks = 100 so that all fibers are included. After that I got the following image. How do I find the length now?
EDIT2 - I found a research article on how to calculate length using Hough Transform but I'm not able to implement it in MATLAB. Someone please help
If your images are all as clean as the one you posted, it's quite an easy problem.
The very first technique I'd try is using a Hough Transform to estimate the line parameters, and there is a good implementation of the algorithm in OpenCV. After you have them, you can estimate their length any way you want, based on whatever other constraints you have.
Problem is two-fold as I see it:
1) locate start and end point from your starting position.
2) decide length between start and end points
Since I don't know your input data I assume it's pixel data with a 0..1 data on each pixel representing it's "whiteness".
In order to find end points I would do some kind of WALKER/AI that tries to walk in different locations, knowing original pos and last traversed direction then continuing along that route until "forward arc" is all white. This assumes fiber is somewhat straight (is it?).
Once you got start and end points you can input these into a a* path finding algorithm and give black pixels a low value and white very high. Then find shortest distance between start and end point, that is the length of the fiber.
Kinda hard to give more detail since I have no idea what techniques you gonna use and some example input data.
Assumptions:
-This image can be considered a binary image where there are only 0s(black) and 1s(white).
-all the fibers are straight and their starting and ending points are on borders.
-we can come up with a limit for thickness in fiber(thickness of white lines).
Under these assumptions:
start scanning the image border(start from wherever you want in whichever direction you want...just be consistent) until you encounter with the first white pixel.At this point your program will understand that this is definitely a starting point. By knowing this, you will gather all the white pixels until you reach a certain limit(or a threshold). The idea here is, if there is a fiber,you will get the angle between the fiber and the border the starting point is on...of course the more pixels you get(the inner you get)the surer you will be in the end. This is the trickiest part. after somehow ending up with a line...you need to calculate the angle(basic trigonometry). Since you know the starting point, the width/height of the image and the angle(or cos/sin of those) you will have the exact coordinate of the end point. Be advised...the exactness here is not really what you might have understood because we may(the thing is we will) have calculation errors in cos/sin values. So you need to hold the threshold as long as possible. So your end point will not be a point actually but rather an area indicating possibility that the ending point is somewhere inside that area. The rest is just simple maths.
Obviously you can put too much detail in this method like checking the both white lines that makes the fiber and deciding which one is longer or you can allow some margin for error since those lines will not be straight properly...this is where a conceptual thickness comes to the stage etc.
Programming:
C# has nice stuff and easy for you to use...I'll put some code here...
newBitmap = new Bitmap(openFileDialog1.FileName);
for (int x = 0; x < newBitmap.Width; x++)
{
for (int y = 0; y < newBitmap.Height; y++)
{
Color originalColor = newBitmap.GetPixel(x, y);//gets the pixel value...
//things go here...
}
}
you'll get the image from a openfiledialog and bitmap the image. inside the nested for loop this code scans the image left-to-right however you can change this...
Since you know C++ and C, I would recommend OpenCV
. It is open-source so if you don't trust anyone like me, you won't have a problem ;). Also if you want to use C# like #VictorS. Mentioned I would use EmguCV which is the C# equivilant of OpenCV. Tutorials for OpenCV are included and for EmguCV can be found on their website. Hope this helps!
Download and install the latest version of 3Dslicer,
Load your data and go the the package>EM segmenter without Atlas>
Choose your anatomical tree in 2 different labels, the back one which is your purpose, the white edges.
The choose the whole 2D image as your ROI and click on segment.
Here is the result, I labeled the edges in green and the black area in white
You can modify your tree and change the structures you define.
You can give more samples to your segmentation to make it more accurate.

Resources