Custom line styles for a given range - ios

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.

Related

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

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

How do you extract noisy connected components from an image?

I have a number of polygonal regions (red) in an image delineated by line segments (cyan). However the lines are noisy and incomplete, they aren't perfectly straight and the have chunks missing. Is there a way to robustly extract the intended red polygons?
If the lines were clean and not broken up connected components would solve this nicely. I've experimented with trying to complete the line segments using Hough transform with little success.
EDIT: Another thought I had was to detect the intersection points of the line segments by first taking the medial axis tranform of the cyan pixels then having a sliding window move over the image and finding windows where there are three or more separate red regions which would indicate locations of cyan intersections. But then not sure what next ..
I know you probably tried this out, but... Did you apply some morphology? maybe some dilations followed by some erosions, maybe at a ratio of 5:2 to preserve and enhance the connections of the components. Did you test using different Structuring Elements?

Using a straight line in ScatterPlot Coreplot iOS

I'm trying to draw a graph using the coreplot library. I'm looking for a way to change the dataLineStyle of the graph so that all the dots will be connected in a straight line, without any playful turns. If needed, I can provide more information.
Is there any way to achieve this?
[EDIT]
I have included a picture to better understand what I'm talking about. I would not like the Graph Line to go above or under the data points.
Regression lines aren't built into Core Plot. You can use one scatterplot to draw the data points with just plot symbols and no data line. Use a second scatter plot to draw the regression line. It only needs two data points, one for each end of the line. You'll have to compute the regression coefficients yourself.
The lines connecting the data points are controlled by the interpolation property. The default is CPTScatterPlotInterpolationLinear which is what you want.

Extract coordinates from image file

How to get an array of coordinates of a (drawn) line in image? Coordinates should be relative to image borders. Input: *.img . Output array of coordinates (with fixed step). Any 3rd party software to do this? For example there is high contrast difference - white background and color black line; or red and green etc.
Example:
Oh, you mean non-straight lines. You need to define a "line". Intuitively, you might mean a connected area of the image with a high aspect ratio between the length of its medial axis and the distance between medial axis and edges (ie relatively long and narrow, even if it winds around). Possible approach:
Threshold or select by color. Perhaps select by color based on a histogram of colors, or posterize as described here: Adobe Photoshop-style posterization and OpenCV, then call scipy.ndimage.measurements.label()
For each area above, skeletonize. Helpful tutorial: "Skeletonization using OpenCV-Python". However, you will likely need the distance to the edges as well, so use skimage.morphology.medial_axis(..., return_distance=True)
Do some kind of cleanup/filtering on the skeleton to remove short branches, etc. Thinking about your particular use, and assuming your lines don't loop around, you can just find the longest single path in the skeleton. This is where you can also decide if a shape is a "line" or not, based on how long the longest path in its skeleton is, relative to distance to the edges. Not sure how to best do that in opencv, but "Analyze Skeleton" in Fiji/ImageJ will let you filter by branch length.
What is left is the most elongated medial axis of the original "line" shape. You can resample that to some step that you prefer, or fit it with a spline, etc.
Due to the nature of what you want to do, it is hard to come up with a sample code that will work on a range of images. This is likely to require some careful tuning. I recommend using a small set of images (corpus), running any version of your algo on them and checking the results manually until it is pretty good, then trying it on a large corpus.
EDIT: Original answer, only works for straight lines:
You probably want to use the Hough transform (OpenCV tutorial).
Python sample code: Horizontal Line detection with OpenCV
EDIT: Related question with sample code to skeletonize: How can I get a full medial-axis line with its perpendicular lines crossing it?

How to create a single line/edge from a set of superimposing lines/edges in MATLAB?

I have a set of edges detected from an image using edge detector of MATLAB's computer vision toolbox. All these edges (18 of them) just form two lines. How do I get the lines from these edges? All that I am interested is to find the intersection point of these two lines.
edges looklike
and the hough lines look like
Peter Kovesi's CV website contains a great set of functions for line detection. Look at this example of using them.
Since you mentioned that the intention is to find the "center point" here goes a possible way (not MATLAB specific though):
Clarifications: when you mention
All these edges (18 of them) just form two lines
It's actually two components or contours that are formed. The Hough line transform will give you straight lines: not exactly what you wanted it seems.
Also, the two "lines" or "contours" do not intersect at least from what's seen in the picture. If you want to find the point of closest approach traverse each point on one contour and check the distance between that point and the points on the second contour. Find the minimum distance for each point on the contour. Then select the minimum from that.
If you meant intersection of two straight lines, simply solve the two equations (you can get them from knowing the end-points of the lines).

Resources