Jfreechart vertical line is blurry - jfreechart

I am using JFreechart to generate some plots, and I found the lines in my plot is blurry, but the demo shows that all the lines are thin and without any blurry, I was wondering if there any to generate good quality plot on a panel.

With more information, I can't explain the rendering and resampling artifact illustrated in your question. Starting from MinMaxCategoryPlotDemo1.java in the demo, I added this line to get the PNG image shown.
ChartUtilities.saveChartAsPNG(new File("temp.png"), jfreechart, 1024, 768);
In particular,
I chose a larger size, as it's generally better to have more pixels than fewer when resampling.
I chose PNG, a lossless image format used in the MinMaxCategoryRenderer API image.
Click to enlarge:

Related

Mapbox raster image not working in mobile

In mobile view mapbox renders black image instead of raster image. I suspect this is because of the size of image(3.9 MB), also this is happening mostly on chrome browser for mobile. Please help me find the potential issue here?
This sounds as if you could be running into the No-Data issue, when rendering transparency.
The black background that appears is the part of the raster image that does not contain any data. Generally a raster image is a rectangular grid of pixels. When you are working with data that is not rectangular, there are pixels within the grid that don't contain any data. These pixels are expressed as NoData values and represent the absence of data. GeoTIFFs that are uploaded to Mapbox Studio are displayed as JPEG to save space and make maps load quickly. Since JPEG cannot display transparency, NoData values appear black.
Please see this documentation on how to resolve this:
https://docs.mapbox.com/help/troubleshooting/raster-transparency-issues/#why-black-backgrounds-appear

how to scale an image with gimp and save the actual scale and all the white space

there are a ton of scaling instructions for GIMP but all of them tell you to scale and save easy peasy. I feel like I'm taking crazy pills.
This is what my save or export generates:
How can I simply export a selection? Shouldn't the GIMP instructions include this detail? Sorry for ranting.
In Gimp (and some other popular image editors) the image you work on is actually made of separate images (a.ka.a layers) held together on a "canvas". The "canvas" gives the size of the final image.
There are three different ways to scale things and you have to use the right one:
The Scale tool : scales the active layer by dragging corners. Doesn't change the size of the canvas. This is probably what you used.
Layer>Scale layer: scales the active layer by providing explicit dimensions. Doesn't change the size of the canvas.
Image>Scale image: scales the whole image contents and the canvas. This is probably what you should have used.
What happened to give you the image above is that you resized the layer using the Scale tool, so you got a tiny image in the corner of the canvas, which didn't change size. The uncovered part of the canvas was displayed as a checkerboard pattern. If you exported to a format that supports transparency such as PNG or GIF the image would have been transparent, but since you exported to JPG which doesn't support transparent images Gimp replaced the transparent part by the default background color.
Everything is well explained on their website. https://www.gimp.org/tutorials/GIMP_Quickies/

convert pdf with 300dpi bitmaps to svg

I'm creating a tool to convert pdf's into svg. These pdf's contain graphical data, including large bitmaps at 300 dpi and a bunch of vectors as well. Poking around here on stackoverflow, I've found pdf2svg, which great -- works like a charm, and the vector data is perfect. But it looks like the bitmaps are getting downscaled to 72dpi. The dimensions are still 8x10 in inches, but you can tell that the dpi isn't right when you zoom in. Soft of makes sense that the default values would presume 72 dpi, but I need the full resolution bitmap images.
pdf2svg uses poppler and cairo to make the conversion. I've poked around in the code, and I see where it's creating a poppler page and a cairo surface, and I've seen in the documentation that a poppler page has a concept of "scale" that seems relevant, but I can't figure out where to plug it in. I tried (experimentally) hardcoding the height and width passed into cairo_svg_surface_create to the correct values, but it made the dimensions applied to the whole svg larger, without affecting the embedded bitmap.
poppler_page_get_size (page, &width, &height);
// Open the SVG file
surface = cairo_svg_surface_create(svgFilename, width, height);
drawcontext = cairo_create(surface);
// Render the PDF file into the SVG file
poppler_page_render(page, drawcontext);
cairo_show_page(drawcontext);
I don't think what I'm trying to do is very esoteric, so I'm hoping someone who has experience with the libraries will see my error right away. Any help, of course, would be immensely appreciated.
I just made the change to the source as described in http://lists.freedesktop.org/archives/poppler/2011-December/008451.html and it worked perfectly - the images seem to be at their native resolution.
Replace
poppler_page_render(page, drawcontext);
with
poppler_page_render_for_printing(page, drawcontext);
Does cairo_surface_set_fallback_resolution() perhaps help? (No, I'm not even sure about this myself)

Can I read a specific image row using libjpeg?

Using libjpeg, if possible, I would like to read a row from the middle of a JPEG image without reading all the preceding rows. Can this be done?
The answer is almost certainly "yes you can, but it will take more effort than you want".
A JPEG image is a stream of markers that contain either information global to the whole compressed image, or information related to specific portions of the image. The compression works by breaking the image into color planes, possibly changing color spaces to one where the color information can be down-sampled, and within each plane operating on 8x8 pixel blocks.
For instance, it is possible to rotate a compressed image by 90 degrees if it is sized such that it is made up of only whole blocks by only transposing the basic blocks and the coefficients inside each block; i.e. without uncompressing, rotating the real image, and recompressing.
Given that, your approach would be to parse the marker stream on the way into the library, passing all the markers that are global to the image, modifying any related to image size, and dropping markers containing coefficients that lie outside your cropping rectangle.
You will likely need to further crop the result if the restriction of cropping to complete basic blocks is too coarse.
What isn't clear to me is whether there is any real win over the alternative, which is to crop the results as it comes out of the library. The library is highly configurable, so you can provide an uncompressed data consumer function that discards all pixels outside your cropping rectangle and only saves pixels you want to keep.

How to overlay text or markers on an bmp image

I'm working with an image processing project where I'm trying to locate features on a .bmp image. I'm writing the whole source code in C.
The algorithm I'm developing is going to search for some features, if a desired feature was found by the algorithm then it is going to create a point (x co-ord, y co-ord), now I want to overlay this point on the image with a green or red DOT.
As of now its only a point, later on I wish to draw a box around a group of features- for example a face.
I don't know how to do this, I'm developing this in Linux (Ubuntu 9.04) environment, can anyone suggest what I should do?
Vikram
Take a look at ImageMagick as well. I've used it in the past with Perl, but it has a C interface as well.
ImageMagick® is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
I would recommend using Cairo for your drawing. What you can do is load the image into an Image Surface, do your processing on the image surface using direct pixel access, and then use a Cairo context to draw what you need. The library also supports text using libpango, and Ubuntu loves the use of Cairo since GTK uses it. There are many tutorials for Cairo as well if you search around. The main site has some already.

Resources