1

I have an image that is created by ray casting a bunch of vectors on to a mesh with a uv map (in blender). There are not enough vectors to completely cover the image so I'd like a way to fill the rest of the image with the closest non zero color. I've been looking into some techniques with convolutions in numpy etc but can't really find what I need, attached is an example of an image I'm working with - png with RGBA.

[Edited to add] Possibly a better description of what I am trying to do: for each pixel that doesn't have a cast color (ie black) I need to find the closest pixel with a cast color based on the distance away, not based on how similar the RGB values are.

enter image description here

  • not my field but how can you do that without knowing which parts of the image are black because they are so and the ones that are black because have to be filled ?? – pippo1980 Aug 13 '21 at 15:35
  • think that the approach could be somehing like this https://stackoverflow.com/questions/61845050/changing-the-pixels-of-an-image-to-the-closest-color-from-a-given-set-of-colors but applying it only to pixels next to colored/filled ones iteration by iteration untill there are no more 0,0,0 RGB pixel in the image. Is it a valid/sounding approach ? – pippo1980 Aug 13 '21 at 15:44
  • if you can reverse https://stackoverflow.com/questions/60008020/find-closest-rgb-color-for-every-pixel-in-image you could find closest black pixel to rgb ones and convert them to same rgb value and iterate it untill no black pixel are n the image – pippo1980 Aug 13 '21 at 15:51
  • I am bookmarking this question.... – pippo1980 Aug 13 '21 at 15:52
  • I make the lowest projected color [1,1,1] - in a final version I may key off the alpha channel (one if that pixel has been cast, otherwise zero) – Matthew Blackwood Aug 14 '21 at 11:54
  • Appreciate the quick responses, unfortunately I may not have detailed my question well - for each pixel that doesn't have a cast color (ie black) I need to find the closest pixel with a cast color based on the distance away, not based on how similar the RGB values are. – Matthew Blackwood Aug 14 '21 at 11:59
  • 1
    trying to recapitulate , you have an rgb array with Nan values , just add to x,y the value of the pixel that is not NaN and has the shortest euclidean distance from x,y. Kind of long: calculating all the euclidean distances from x,y ( for each Nan x,y) sort them and choose the smallest. Is that reasonable ? – pippo1980 Aug 14 '21 at 14:28
  • I should start by just brute forcing it, I was hoping for a nice easy, elegant way :). I've been using Pandas a lot, I'll see what I can come up with. – Matthew Blackwood Aug 15 '21 at 11:51
  • do you have time to explain difference between 'some techniques with convolutions i and ' just brute forcing it' ? – pippo1980 Aug 15 '21 at 11:56

0 Answers0