Discussion:
[elm-discuss] Linear algebra (matrix, vectors, ...) in the context of image processing
Matthieu Pizenberg
2017-03-03 05:01:11 UTC
Permalink
I'm currently looking for a library to do some basic image processing and
matrix manipulation stuff.

I have a research background (mostly spending time in Matlab), and
currently preparing a user study. Elm has been great for my needs so far,
but I'm encountering now a few obstacles.

Types and functions regarding the manipulations I might need could be:
* Binary image mask ~> could be some kind of Matrix/Array Bool
* Boolean mask operations (And, Or, ...) ~> I guess if using a _ Bool data
structure, this is not complicated
* Mask generation from simple polygons
* etc.

The second issue, is the visualization of these masks/images. Until now, I
was only dealing with raw png images, and polygons. So the obvious choice
of representation was SVG. Now I'd also like to visualize those masks (that
would be computed in some form of matrix data type). I do not know of a
trivial way to do this in svg?

Finally, I wonder how to retrieve those (binary mask or not) images and
transform them in a more computing-friendly data type (kind of imread in
Matlab). Since I don't think Elm is able to manipulate byte data types,
this doesn't seem trivial to me.

Any thought regarding these problematics?
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ian Mackenzie
2017-03-03 12:54:01 UTC
Permalink
For your second question, I know there's work being done currently on supporting the Canvas API in Elm (https://github.com/elm-community/canvas), which may be more appropriate for visualizing bitmap data than SVG, but it's still very experimental.
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matthieu Pizenberg
2017-03-04 10:29:05 UTC
Permalink
Thanks Ian for the link. I will keep this work in mind though I don't think
I could use it for my current project. It seems focused on rgbd matrix data
type which is great for transparent dynamic graphics. Svg representation
does really suits my needs for now since I'm visualizing non changing data
(or rarely, or path/polygon types of data) in changing frame (zooming,
moving, etc). So svg transformations are the only thing to change, no
canvas recomputation.

For my image binary masks representation, I just stumbled upon Noah's
elm-flat-matrix
<http://package.elm-lang.org/packages/eeue56/elm-flat-matrix/latest/> lib
which feels very interesting. The only thing a bit weird for matrix
manipulation is the row-major implementation and notation (first index
refers to column). This makes sense in the context of image manipulation
though (with x corresponding to the width, being always the first
coordinate).

Regarding the transformation of the image file to matrix data, I feel like
I have no other choice than to do it in JS. I found some interesting
example of how to deal with this in the jimp
<https://github.com/oliver-moran/jimp/blob/master/browser/src/jimp-wrapper.js>
lib code. Since I can't escape JS for now, I might also try to visualize
the binary masks with ports. The idea being that I create a dedicated
tag+id in the elm view code. Pass the data and the id of the tag in which
JS should include the visualization by generating the data uri to put in
the dedicated tag. (hoping following elm view updates will not change this
tag if no reason to - maybe by using html keyed ?).

If anyone thinks I'm heading for a fall, please tell me.

PS: Ian your OpenSolid repositories rock. I just switched to it instead of
my previous home made solutions. I might have propositions also for an
addition into the the Polygon2d and LineSegment2d modules but that's
another story.

On Mar 3, 2017 20:54, "Ian Mackenzie" <***@gmail.com> wrote:

For your second question, I know there's work being done currently on
supporting the Canvas API in Elm (https://github.com/elm-community/canvas),
which may be more appropriate for visualizing bitmap data than SVG, but
it's still very experimental.

--
You received this message because you are subscribed to a topic in the
Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/to
pic/elm-discuss/BbPBd8Rq2Pw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ian Mackenzie
2017-03-05 16:20:32 UTC
Permalink
I also wonder how memory efficient a pure Elm solution could be, as currently there's no support for binary or packed data representation. That alone might argue for keeping the image data itself on the JavaScript side where you (or the libraries you use) can pull all sorts of tricks with typed arrays and stuff like that. I think ultimately Elm could be a great language for working with binary data but it's not there yet.

Glad you're finding OpenSolid useful! Certainly happy to discuss feature requests - for the initial release I was concentrating on getting the data types and overall structure/'grammar' of the package right, but that means there are lots of places where useful individual bits of functionality are not yet implemented.
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matthieu Pizenberg
2017-05-02 09:20:18 UTC
Permalink
Post by Ian Mackenzie
I think ultimately Elm could be a great language for working with binary
data but it's not there yet.
Indeed ^^. In case you're still interested, I posted there what I did (at
the end) :
https://groups.google.com/forum/#!searchin/elm-discuss/pizenberg|sort:relevance/elm-discuss/u_ui3PlDwLc/uLf9yhNjAgAJ
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...