vecino Well-Known Member Licensed User Longtime User Feb 7, 2015 #1 Hello, is it possible or not possible? The user uploads an image. The software "finds" the boxes and filled with color. The software saves the new image. Impossible? User image: Generated image:
Hello, is it possible or not possible? The user uploads an image. The software "finds" the boxes and filled with color. The software saves the new image. Impossible? User image: Generated image:
DonManfred Expert Licensed User Longtime User Feb 7, 2015 #2 vecino said: Impossible? Click to expand... No Upvote 0
RandomCoder Well-Known Member Licensed User Longtime User Feb 7, 2015 #3 Very helpful @DonManfred (and completely off-topic but I like the new Avatar ). So it's got me thinking, how would someone go about doing this? I'm thinking that maybe create a Type called box... Code: Copy Type Box(Num As Int, x1 As Int, y1 As Int, x2 As Int, y2 As Int, Colour As Int) Then create a canvas containing the image and scan from to left to right getting each individual pixel. Black pixels denote the edge of a box. Move down to the next row of pixels and repeat also checking for the bottom edge of the boxes. Or, would it be easier to find the first box edge and bottom then move to finding the next box edge and bottom Upvote 0
Very helpful @DonManfred (and completely off-topic but I like the new Avatar ). So it's got me thinking, how would someone go about doing this? I'm thinking that maybe create a Type called box... Code: Copy Type Box(Num As Int, x1 As Int, y1 As Int, x2 As Int, y2 As Int, Colour As Int) Then create a canvas containing the image and scan from to left to right getting each individual pixel. Black pixels denote the edge of a box. Move down to the next row of pixels and repeat also checking for the bottom edge of the boxes. Or, would it be easier to find the first box edge and bottom then move to finding the next box edge and bottom
DonManfred Expert Licensed User Longtime User Feb 7, 2015 #4 RandomCoder said: and completely off-topic Click to expand... It is NOT off-topic! He asked "Impossible?" and i gave the answer that it is not impossible. SO WHAT? Last edited: Feb 7, 2015 Upvote 0
RandomCoder said: and completely off-topic Click to expand... It is NOT off-topic! He asked "Impossible?" and i gave the answer that it is not impossible. SO WHAT?
RandomCoder Well-Known Member Licensed User Longtime User Feb 7, 2015 #5 Oh you do seem techy today @DonManfred You have misunderstood me, I was referring to myself being off topic with regard to your Avatar! That was all I meant by it Upvote 0
Oh you do seem techy today @DonManfred You have misunderstood me, I was referring to myself being off topic with regard to your Avatar! That was all I meant by it
S sorex Expert Licensed User Longtime User Feb 7, 2015 #6 it's possible but it might be slow on cheaper slower devices. Last edited: Feb 7, 2015 Upvote 0
DonManfred Expert Licensed User Longtime User Feb 7, 2015 #7 RandomCoder said: You have misunderstood me, I was referring to myself being off topic with regard to your Avatar! That was all I meant by it Click to expand... Sorry then I like the new avatar too Upvote 0
RandomCoder said: You have misunderstood me, I was referring to myself being off topic with regard to your Avatar! That was all I meant by it Click to expand... Sorry then I like the new avatar too
vecino Well-Known Member Licensed User Longtime User Feb 7, 2015 #8 Then, do you have any idea? Upvote 0
T Troberg Well-Known Member Licensed User Longtime User Feb 7, 2015 #9 Here's how I'd do it: 1. Find a white pixel. 2. Do a floodfill from that pixel in another color. 3. Repeat until there are no white pixels left. Upvote 0
Here's how I'd do it: 1. Find a white pixel. 2. Do a floodfill from that pixel in another color. 3. Repeat until there are no white pixels left.
stevel05 Expert Licensed User Longtime User Feb 7, 2015 #10 This is tricky, it will depend on the quality of the image. Flood fill would be good (is there a library that implements this?) if boundaries are all solid, and the background is white, not grey, or off white. I did a quick scan of the internet and there are a few links to java code that may do it. Try searching for one that looks promising and see if it can be ported. I'm sure there is a 'proper' way to do it and you may just stumble across a quick or at least accurate method. Upvote 0
This is tricky, it will depend on the quality of the image. Flood fill would be good (is there a library that implements this?) if boundaries are all solid, and the background is white, not grey, or off white. I did a quick scan of the internet and there are a few links to java code that may do it. Try searching for one that looks promising and see if it can be ported. I'm sure there is a 'proper' way to do it and you may just stumble across a quick or at least accurate method.
vecino Well-Known Member Licensed User Longtime User Feb 7, 2015 #11 stevel05 said: .. if boundaries are all solid, and the background is white, not grey, or off white. Click to expand... Yes, black and white Upvote 0
stevel05 said: .. if boundaries are all solid, and the background is white, not grey, or off white. Click to expand... Yes, black and white
S sorex Expert Licensed User Longtime User Feb 7, 2015 #12 the problem here is that you need to start over again after every fill since you don't know where the fills have drawn already. so the more polygons you have the slower it will become. this is not the case if the fill only occurs on an offset based on a press/touch on the picture. Upvote 0
the problem here is that you need to start over again after every fill since you don't know where the fills have drawn already. so the more polygons you have the slower it will become. this is not the case if the fill only occurs on an offset based on a press/touch on the picture.
S sorex Expert Licensed User Longtime User Feb 7, 2015 #14 can they only upload poly pictures like the one in the example or are they free? if it is only squares you can make it really fast. Upvote 0
can they only upload poly pictures like the one in the example or are they free? if it is only squares you can make it really fast.
vecino Well-Known Member Licensed User Longtime User Feb 7, 2015 #15 The polygons may be squares, rectangles, triangles, etc. Upvote 0
S sorex Expert Licensed User Longtime User Feb 7, 2015 #16 ok, then you can't benefit the fast scanning and plotting methods I had in mind. Upvote 0
T Troberg Well-Known Member Licensed User Longtime User Feb 9, 2015 #18 How many polygons can you expect? If it's few, my floodfil method will be plenty fast, but if it's thousands, you might want to reconsider. Upvote 0
How many polygons can you expect? If it's few, my floodfil method will be plenty fast, but if it's thousands, you might want to reconsider.
S sorex Expert Licensed User Longtime User Feb 9, 2015 #19 if you know in advance where they are it can be fast but you need to rescan the image after every fill again to find and do the next none filled area. you can store the last position then you can skip some of it. Upvote 0
if you know in advance where they are it can be fast but you need to rescan the image after every fill again to find and do the next none filled area. you can store the last position then you can skip some of it.
T Troberg Well-Known Member Licensed User Longtime User Feb 9, 2015 #20 You can also do the scanning smarter. Remember how far you scanned last time before finding a white pixel, and resume from that point the next time. It's not like non-white pixels are going to turn white, so no need to re-scan. Smart scanning like this, combined with flood fill, is probably as close to optimal as you can get with a reasonably simple algoritm. Upvote 0
You can also do the scanning smarter. Remember how far you scanned last time before finding a white pixel, and resume from that point the next time. It's not like non-white pixels are going to turn white, so no need to re-scan. Smart scanning like this, combined with flood fill, is probably as close to optimal as you can get with a reasonably simple algoritm.