plotly.js "pseudo" histogram for time-series data? - time-series

I am trying to figure out how to create this overlaid plot of time-series data, where one of the series should "look" like a histogram.
The problem is I could not figure out how to combine/overlay a histogram with time series data and line/scatter plot and get the histogram xbins to work with the date time data, etc.
So I was also trying to use a bar chart, and create a "pseudo histogram" by removing the gaps between bars, adding outlines, and so forth but that seems fruitless as I don't see a way to control all the borders/lines to that level of control.
The result I am looking for is roughly like so;
Which to me looks like the best match for a plot type should be a histogram, but again I could not figure out how to make that work overlaid with the same x axis as the line/scatter time-series data.
Can anyone offer ideas or point me to an example that might help me understand how to do this ?
I guess I also need to figure out how to align the y-axis scales of the two series also, but that I expect is a different topic...
I am specifically using plotly.js / Javascript

Related

Creating a porosity map by interpolating between multiple overlapping grid squares

I have a binary image with black particles and white pore space. I am trying to observe the porosity variation across the image. To do this I have originally been using a square grid and measuring the porosity (ratio of black to white pixels) in each grid. I have then been uploading these values to matlab as XYZ coordinates, with X and Y being the centres of each grid and Z being the porosity value. I have then interpolated between these values to produce a porosity map.
However, when using a single square grid, the porosity map is not very representative of the binary image because the grids are coarse. However, I cannot reduce the grid size due to theoretical reasons in what I am trying to do.
However, I have found that if I overlay multiple grids, but which are shifted to the right or downwards incrementally, then I can upload these new XYZ values to matlab and interpolate between them which produces a much better porosity map.
The issue is that I can't find any reference to this method anywhere and so does anyone know if this technique is used at all or in any literature?. Also would interpolating between overlapping squares cause any issues because the porosity map produced using the overlapping squares looks good?
I have been searching the literature for what feels like an age looking for the answer to this question so I'd really appreciate any help.
Instead of using a coarse grid and interpolating between the values, I would use a sliding window (the same size as the cells your coarse grid) and compute the porosity at every position.
The multigrid approach will probably produce artifacts (aliasing issues) and is difficult to interpret.

How to plot 2d array with hicharts easily?

I have a 2d Array containing an heatmap representation 6000*6000 pixels, i saw the example on highchart site and especially this one
jsfiddle.net/tZ6GP/5/
and it works.
But my grid is regulary spaced so it's a pity to be forced to create a new array 3 times bigger my original.
Do you know if there is a mean or an other type of chart more simple that could be lighter ? or maybe another library
Best regards

Custom line styles for a given range

I'm trying to highlight a portion of a scatter/line plot, but using separate plots for each highlight and get them overlaid on top of the original plot is not working for me because the original plot is doing cubic curve smoothing and I need more points in the highlight than required for the curve to fit the one in the back.
I haven't found any delegate/data source way of specifying a line style for a given range in the documentation. Is there a way of achieving this?
If not possible, is my approach of multiple plots the way to go or is there something else you'd recommend?
There is no way to specify different line styles for separate data ranges. Your solution of multiple plots is the right one, although as you discovered, it won't work with smoothed lines.
You could do the smoothing yourself by turning off the curved line interpolation and adding additional plot points between the known data points. Then you would know where to separate the data for the individual plots.

Finding data entry points in a blank, scanned application form

I am a relative newcomer to image processing and this is the problem I'm facing - Say I have the image of an application form, like this:
Now I would like to detect the locations of all the locations where data is to be entered. In this case, it would be the rectangles divided into a number of boxes like so(not all fields marked):
I can live with the photograph box also being detected. I've tried running the squares.cpp sample in the OpenCV sources, which does not quite get me what I want. I also tried the modified version here - the results were worse(my use case is definitely very different from the OP's in that question).
Also, Hough transforming to get the lines is not really working with/without blur-threshold as the noise in scanned image is contributing to extraneous lines, and also, thresholding is taking away parts of the combs(the small squares), and hence the line detection is not up to the mark.
Note that this form is not a scanned copy of a printed form, but the real input might very well be a noisy, scanned image of a printed form.
While I'm definitely sure that this is possible(at least with some tolerance allowed) and I'm trying to get at the solution, it would be really helpful if I get insights and ideas from other people who might have tried something like this/enjoy hacking on CV problems. Also, it would be really nice if the answers explain why a particular operation was done (e.g., dilation to try and fill up any holes left by thresholding, etc)
Are the forms consistent in any way? Are the "such boxes" the same size on all forms? If you can rely on a consistent size, like the character boxes in the form above, you could use template matching.
Otherwise, the problem seems to be: find any/all rectangles on the image (with a post processing step to filter out any that have a significant amount of markings within, or to merge neighboring rectangles).
The more you can take advantage of the consistencies between the forms, the easier the problem will be. Use any context you can get.
EDIT
Using the gradients (computed by using a Sobel kernel in both the x and the y direction) you can weed out a lot of the noise.
Using both you can find the direction of the gradients (equation can be found here: en.wikipedia.org/wiki/Sobel_operator). Let's say we define a discriminating feature of a box to be a vertical or horizontal gradient. If the pixel's gradient has an orientation that's either straight horizontal or straight vertical, keep it, set all else to white.
To make this more robust to noise, you can use a sliding window (3x3) in which you compute the median orientation. If the median (or mean) orientation of the window is vertical or horizontal, keep the current (middle of the window) pixel, otherwise set it to white.
You can use OpenCV for the gradient computation, and possibly the orientation/phase calculation, but you'll probably need to write the code it do the actual sliding window code. I'm not intimately familiar with OpenCV

Converting images to time series

I'm experimenting using reservoir computing techniques to classify images, but I'm not sure how to convert an arbitrary image to a time series.
I found this approach but it doesn't seem to be general enough.
Thanks!
As defined in that article, a time series is just a single-value function of one variable. However, an image is, in general, a multi-value function of two variables. So, in order to convert from an image to a 'time series', you're projecting down from a higher dimensional space to a lower dimensional one (for example, the radial scanning technique described collapses the image as a whole into an outline, which reduces the dimension to one). A key point is that these projections all 'lose data'. Since they're all lossy, there isn't going to be a 'general' solution that works for all uses of all images.. choosing what data you can afford to lose based on your intended application is a key aspect of using this technique. So, I guess my answer is that there is no single general way to convert an image to a 'time series' that works well for all applications.
I would think along those lines.
An image is a static two dimensional array of pixels recorded of a period in time.
A time series is non-static just like a video is a series of images going from one frame to the next in time.
Not sure I answered the question but I hope this helps.

Resources