Is there a (simple) way to get the average value for pixels 'behind' geometric objects? I whant to do some mosaiic-style path and determine colors for each tile based on a raster/pixel image.
clarification image
I'd like to have some getAvgValue(Path1) functionality… or SVG-mosaiic-filter or anything with that functionality
[partially solved] Way to get average Pixelvalue of a picture segment defined by geometric object/path?
[partially solved] Way to get average Pixelvalue of a picture segment defined by geometric object/path?
Last edited by aik on Thu Jul 07, 2016 9:22 pm, edited 1 time in total.
Re: Way to get average Pixelvalue of a picture segment defined by geometric object/path?
As far as I know the tiled clones are the closest at the moment.
Well you can use trace bitmap to sort out the image to separate colours.
Well you can use trace bitmap to sort out the image to separate colours.
Re: Way to get average Pixelvalue of a picture segment defined by geometric object/path?
The dropper tool can average over circle-shaped areas (just click and drag). In many cases, that may suffice in terms of precision.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Re: Way to get average Pixelvalue of a picture segment defined by geometric object/path?
Thanks for answers =)
Unfortunatly your proposed solutions were not precise enough or can not be done automaticly via script.
I found a solution though it is not very fast - javascript based - so slow firefox crashes before finishing, but chromium does it.
Outline of what I did:
- have Image with pixeldata as canvas object
Unfortunatly your proposed solutions were not precise enough or can not be done automaticly via script.
I found a solution though it is not very fast - javascript based - so slow firefox crashes before finishing, but chromium does it.
Outline of what I did:
- have Image with pixeldata as canvas object
Code: Select all
for each pixel on canvas
for each object
check if object is containing pixel(x,y)
store pixel value in array object->pixelvalue
rof
rof
calculate mean color for each object in array
Re: [partially solved] Way to get average Pixelvalue of a picture segment defined by geometric object/path?
Maybe you can skip the comparison with all your shapes.
create white image the same size of original
draw all your shapes onto this new image with ascending colors (make sure you're NOT using antialiasing)
iterate all pixels in the new image.
read the color of the pixel in the new image => this is the index [i] of your shape
(test if white it doesn't belong to any of your shapes)
read the color at same coordinates in the original =>push it to the array of pixel colors for shape i
for each shape compute mean of found pixels
create white image the same size of original
draw all your shapes onto this new image with ascending colors (make sure you're NOT using antialiasing)
iterate all pixels in the new image.
read the color of the pixel in the new image => this is the index [i] of your shape
(test if white it doesn't belong to any of your shapes)
read the color at same coordinates in the original =>push it to the array of pixel colors for shape i
for each shape compute mean of found pixels
Code: Select all
cache = new image(width,height)
cache.Fill(#fff)
For i = 0 to shapes.length
shapes[i].fill(i)
For each pixel in cache
Number of shape = cache.getImageData(pixel.x,pixel.y...)
Shapepixels[number of shape]+=image.getImageData(pixel.x,pixel.y...)
For each shapepixels
Compute mean
Re: [partially solved] Way to get average Pixelvalue of a picture segment defined by geometric object/path?
there's place for some optimization on your code
exit as soon as you find the object
pixel x+1,y probably belongs to the same object than pixel x,y => check this object first
exit as soon as you find the object
pixel x+1,y probably belongs to the same object than pixel x,y => check this object first
Code: Select all
lastobject = object;
for each pixel on canvas
if lastobject contains(x,y)
...
else
for each object!=lastobject
check if object is containing pixel(x,y)
store pixel value in array object->pixelvalue
lastobject = object
exit for
rof
rof
calculate mean color for each object in array