[SOLVED]Writing sub-images From an image with 50% overlappin
Posted: 2012-05-16T09:47:01-07:00
hi everyone..
Im using image magick for a quite some time and im stuck at a point now...can any one please hep how to output different subimages from a big images with 50% overlapping using magick wand and c language. I maintain the r,g,b values of big image in a big 1D array and i have to write the output to different sub-images with 50% overlapping. i figured how to write mutiple sub-images from a big 1D array seperately but im stuck at 50% overlapping. im including my code on how to write different multiple sub-images seperately with no overlapping. Can anyone please help me in this.
Im using image magick for a quite some time and im stuck at a point now...can any one please hep how to output different subimages from a big images with 50% overlapping using magick wand and c language. I maintain the r,g,b values of big image in a big 1D array and i have to write the output to different sub-images with 50% overlapping. i figured how to write mutiple sub-images from a big 1D array seperately but im stuck at 50% overlapping. im including my code on how to write different multiple sub-images seperately with no overlapping. Can anyone please help me in this.
Code: Select all
for(int ip=0;ip<v.img_cnt;ip++) // img_cnt is already predefined
{
MagickWand *image;
MagickBooleanType status;
MagickWandGenesis(); // to initialize the magick-wand Environment
image=NewMagickWand(); // To create the wand to store image
MagickSetSize(image,v.width,v.height);
status = MagickReadImage(image, "xc:none" );
if (status == MagickFalse)
printf ("status problem");
PixelIterator *new_iterator;
PixelWand **new_pixels;
a=0;
while(a<v.n_sbimg)
{
new_iterator=NewPixelRegionIterator(image,v.col[a],v.row[a],v.sbimg_wdt,v.sbimg_hgt);
for(y=0;y<v.sbimg_hgt;y++)
{
new_pixels = PixelGetNextIteratorRow(new_iterator, &v.sbimg_wdt);
for(x=0;x<v.sbimg_wdt;x++)
{
int t=loc(y,x,v.sbimg_wdt)+ a*v.sbimg_pxl+ip*(v.width*v.height*3); //calculates position of r,g,b values in the 1D array
unsigned char r=new_data[t],g=new_data[t+1],b=new_data[t+2]; //new_data contains new image r,g,b values
char color[64];
sprintf(color,"rgb(%d,%d,%d)",r,g,b);
PixelSetColor(new_pixels[x],color); // this function sets the color of pixel.
PixelSyncIterator(new_iterator);
}
}
a++;
}