- Community Home
- :
- Discussion Forums
- :
- Most Active Software Boards
- :
- LabVIEW
- :
- Image/Picture to to 2d Array Without Using PictureToPixmap

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

10-21-2016 01:49 PM

Options

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@re-fuse wrote:... (with filled interior) ...

What defines the "interior"? can you show a sketch of the final image? Do you just want the lines to be wider than 1 pixel?

10-21-2016 02:18 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Or are you just talking about line interpolation between defined points? That seems trivial.

10-21-2016 04:26 PM - edited 10-21-2016 04:31 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@altenbach wrote:Or are you just talking about line interpolation between defined points? That seems trivial.

Here's one possible solution for that. Modify as needed.

(this is just a quick a dirty draft. I am sure it can be improved).

Of course you would need to include the correct scaling between values and indices. My algorithm should be applied once the data is quantized to pixels.

10-21-2016 04:59 PM - edited 10-22-2016 11:42 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Once you have a continuous outline, a flood fill is simple If you can make certain assumptions about the shape. Is that what you want?

10-22-2016 01:27 PM - edited 10-22-2016 01:29 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@altenbach wrote:

What defines the "interior"? can you show a sketch of the final image? Do you just want the lines to be wider than 1 pixel?

your last post is exactly what i want.

in this sketch you can see the shape before and after filling it.

later on i used the point coordinates from the filled shape to draw the picture.

how exactly did you do the flood fill? without using picture functions i assume.

10-22-2016 03:34 PM - edited 10-22-2016 03:36 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@re-fuse wrote:

how exactly did you do the flood fill?

There are plenty of flood fill algorithms discussed on the web (start here) but they require a definition of what is "inside" and "outside" In your case, the array border seems to be outside and you have two independent areas to fill. Is this always the case? You only have one array of points. How do you know when one curve ends and the other starts to prevent connecting them? The XY data in the VI you attached earlier is rather boring (just a rectangle), so it wouold be nice to have something with a bit more realistic data. Is the data always symmetric? Would it be sufficient to define the upper curve and just mirror it for the lower half?

re-fuse wrote:later on i used the point coordinates from the filled shape to draw the picture.

At the end you transform the 2D array into a picture. No need for coordinates and no drawing involved.

10-23-2016 05:43 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

altenbach wrote:

There are plenty of flood fill algorithms discussed on the web (start here) but they require a definition of what is "inside" and "outside" In your case, the array border seems to be outside and you have two independent areas to fill. Is this always the case?

i've tried those floodfill algorithm (this one) but i weren't successful. the 1d array of point coordinates define the border of my shape and what's inside and outside.

the problem is that the number of shapes (respectively the number of independent areas to fill) is not always the same ... in the example above i have to 2 shapes but sometimes it's just one (e.g. rectangle), sometimes many more.

that's why the floodfill algorithm didnt work cause i'd have to manually define where's inside/outside for each shape.

altenbach wrote:

How do you know when one curve ends and the other starts to prevent connecting them? The XY data in the VI you attached earlier is rather boring (just a rectangle), so it wouold be nice to have something with a bit more realistic data. Is the data always symmetric? Would it be sufficient to define the upper curve and just mirror it for the lower half?

each shape is defined by a cubic bezier curves. in that beam-splitter example above i have 24x bezier curve, 12x for the upper arm and 1x for the lower arm ... and the last bezier curve ends where the first bezier curve starts so that the shape is complete.

i than transform every cubic bezier curve into 1d array of points using the De Casteljau's algorithm.

unfortunately the data/shape is not always symmetric ... so mirroring is no solution here.

i've attached a VI with more realistic data.

10-23-2016 12:04 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@re-fuse wrote:

that's why the floodfill algorithm didnt work cause i'd have to manually define where's inside/outside for each shape.

I thought that you know that the array edge is "outside", thus you can easily find all the "inside" areas. i.e. all pixels where you cross a border an odd number of times. OTOH, the outside seems to be contiguous, so why not anti-fill the ouside instead? (Start with an U8 array of ones, interpolate the edges and fill with twos, then fill the outside with zeroes. change to boolean array using "not equal zero" or similar).

@re-fuse wrote:

each shape is defined by a cubic bezier curves. in that beam-splitter example above i have 24x bezier curve, 12x for the upper arm and 1x for the lower arm ... and the last bezier curve ends where the first bezier curve starts so that the shape is complete.

You still need to define where one curve ends and the next curve starts, else my algorithm would connect the last point of one area with the first point of the next area and you get one extra line. that messes up the fill algorithm. I don't understand how your numbers add up (24x, 12x, 1x). How many points per curve are there?

10-23-2016 12:10 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@re-fuse wrote:

i've attached a VI with more realistic data.

**The VI does not contain any data**. You need to make the values default before saving and attaching. (Or just right-click the terminal of the control (once it contains the data!) and "create constant". Now delete everything but that constant, save VI under a new name and attach it here.

10-24-2016 03:49 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

altenbach wrote:

I thought that you know that the array edge is "outside", thus you can easily find all the "inside" areas. i.e. all pixels where you cross a border an odd number of times. OTOH, the outside seems to be contiguous, so why not anti-fill the ouside instead? (Start with an U8 array of ones, interpolate the edges and fill with twos, then fill the outside with zeroes. change to boolean array using "not equal zero" or similar).

well i know the inside&outside of each shape cause it is defined by the array edge.

for the floodfill algorithm i'd have to define a starting point and i've always used a point inside the shape ... this way there are of course as many starting points as there are shapes. i've never got the idea to anti-fill the outside cause the outside is always contigous .. silly me!

You still need to define where one curve ends and the next curve starts, else my algorithm would connect the last point of one area with the first point of the next area and you get one extra line. that messes up the fill algorithm. I don't understand how your numbers add up (24x, 12x, 1x). How many points per curve are there?

iam sorry ... i should have explained in more details.

the number of bezier curves that define the whole shape depends on the complexity of the shape.

for example a rectangle consist of 4 lines so you would need 4 bezier curves ... and each bezier curve starts (respectively ends) where the previous curve ends (respectively where the next curve starts).

in case of the beam-splitter shape each arm (upper & lower) is defined by 12 bezier curves. so for the whole beam-splitter i've got 24 bezier curves defining the shape.

the number of points depends on how fine i want each bezier curve to be approximated by equidistant points (de casteljau algorithm).

i've tried your interpolating algorithm ... but it didnt work and i honestly dont know why.

i've attached the current VI. this time with data.

you can see the defining points of each bezier curve and the calculated points based on de casteljau algorithm.

sorry for the empty VI last time .. i've forgot to make all values default.