Click here to Skip to main content
15,559,275 members

Comments by tasumisra (Top 9 by date)

tasumisra 8-Feb-16 11:53am View    
this is how implementation looks like


template<typename t="">
class Image
{
public:

void create(unsigned int width, unsigned int height)
{
_imageData = boost::shared_ptr<t>(new T[width * height]);
_width = width;
_height = height;
}

T getPixel(unsigned int x, unsigned int y) const
{
return _imageData[x * y];
}

void setPixel(unsigned int x, unsigned int y, T pixel)
{
_imageData[x + _width * y] = pixel;
}

// Return a sub-region of pixels
boost::shared_ptr<Image<t> > extractRegion(const Rectangle<t>& region) const
{
boost::shared_ptr<Image<t> > im = new Image<t>();

im->create(region.Width, region.Height);

for(unsigned int y = 0; y < region.Height; y++)
{
for(unsigned int x = 0; x < region.Width; x++)
{
im->setPixel(x, y, getPixel(region.X + x, region.Y + y));
}

}

return im;
}

private:

boost::shared_ptr<t> _imageData;

unsigned int _width;
unsigned int _height;


}
tasumisra 8-Feb-16 11:03am View    
Hello Stefan,
this is pseudo code and i was only expecting indicative solution\design..

but as you pointed out few things i ll try to look into this.

Thanks
tasumisra 8-Feb-16 10:54am View    
Thank you so much Pallini,i have been waiting for your answer and i know you are champion :) can you please help me with some good tutorial\links for the same...

apart from that how to convert 16bit grey scale to 24 bit RGB ... just exploring few things around
tasumisra 8-Feb-16 6:42am View    
Thanks Aescleal,I will try this option.
tasumisra 8-Feb-16 6:34am View    
hi Kornfeld,
i am looking to optimise it for speed,basically i want to create some kind of hash table where it trying to call GetData each time...
any help would be appriciated

Thanks,
Vikas