Prev: How to find a particular pattern in an image for a range of grayscale levels
Next: Multidimensional SAFEARRAYs via COM
From: Malcolm McLean on 28 Jul 2010 08:36 I have a large image in 24-bit rgb format (uint height x width X 3 matrix). I want to paste a sub-image into this image. I'd also like to paint a value into the image using a logical as a mask. This seems impossible to vectorise. picture(y1:y2, x1:x2, 1:3) = [255 0 0]; won't do what I want. picture(y1:y2, x1:x2, 1) = 255; picture(y1:y2, x1:x2, 2) = 0; picture(y1:y2, x1:x2, 3) = 0; works and is barely acceptable. However that only allows me to paste solid rectangular blocks of colour. How can these manipulations be vectorised (it's also necessary to avoid making a temporary copy of the entire image)?
From: Walter Roberson on 28 Jul 2010 10:43 Malcolm McLean wrote: > I have a large image in 24-bit rgb format (uint height x width X 3 matrix). > > I want to paste a sub-image into this image. > I'd also like to paint a value into the image using a logical as a mask. > > This seems impossible to vectorise. > > picture(y1:y2, x1:x2, 1:3) = [255 0 0]; picture(y1:y2, x1:x2, 1:3) = repmat([255 0 0], y2-y1+1, x2-x1+1, 1); > won't do what I want. > picture(y1:y2, x1:x2, 1) = 255; > picture(y1:y2, x1:x2, 2) = 0; > picture(y1:y2, x1:x2, 3) = 0; > > works and is barely acceptable. However that only allows me to paste > solid rectangular blocks of colour. > > How can these manipulations be vectorised (it's also necessary to avoid > making a temporary copy of the entire image)? A logical array as big as "picture" would be have the same dimensions as "picture" but should only be 1 byte per location. Is that acceptable in view of your need to avoid making a temporary copy of the entire image? Is your logical mask effectively only working on a relatively small rectangular subset of the image, with the coordinates of the subset known?
From: Malcolm McLean on 28 Jul 2010 10:55 Walter Roberson <roberson(a)hushmail.com> wrote in message > > Is your logical mask effectively only working on a relatively small > rectangular subset of the image, with the coordinates of the subset known? > The mask represents characters in a font. I want to write a solid colour to arbitrary x, y co-ordindates within the image, using the mask. Also with option for a background. It needs to be fast because I have lots of characters. Creating them as text objects didn't work - it took about five minutes to render, visibly slowing down as the child list became excessively long. So I'm writing them to an image buffer and blitting it out.
From: Malcolm McLean on 29 Jul 2010 04:40 Thanks. It seems that basically there isn't an answer. 3d array manipulations cannot be vectorised except in a few special cases.
From: Walter Roberson on 30 Jul 2010 12:43
Malcolm McLean wrote: > Thanks. It seems that basically there isn't an answer. 3d array > manipulations cannot be vectorised except in a few special cases. Hmmm? They are as vectorizable as 2D array manipulations. |