Sunday, 15 June 2014

qt - Image width and widthstep, now what? -



qt - Image width and widthstep, now what? -

i have question dealing utilize of image's width , widthstep.

i have dimensions image info qbytearray. have widthstep. question how utilize widthstep populate ipl image since image's width 4095, not integer multiple of 8. have populated images widths integer multiples of 8 stuck problem @ hand. general code uses widthstep populate iplimage welcomed , highly appreciated. :d

here part of switch case works; default integer multiple of 8 image width:

default: { iplimage* extracted_sar_image; // our image declaration cvsize size; // size type has width , height attributes size.height = sar_nrows_integer; // height of size size.width = sar_ncols_integer; extracted_sar_image = cvcreateimageheader(size, ipl_depth_8u, 1); extracted_sar_image->imagedata = sar_image_data_2.data(); cvnamedwindow("image", cv_window_normal ); cvshowimage("image", extracted_sar_image); cvmovewindow("image", 100, 100); cvsaveimage("c:/users/z_slant/desktop/generated_extracted_sar_image.bmp", extracted_sar_image); // delay observe image beingness saved cvwaitkey(10000); // deallocates image info cvreleaseimage(&extracted_sar_image); // closes image display window cvdestroywindow("image"); break; }

you have take business relationship byte alignment opencv structure.

1 line in opencv iplimage widthstep bytes long

1 line in qbytearray width bytes long

thus, copying info line line should ok.

qbytearray myarray; iplimage* extracted_sar_image; // our image declaration cvsize size; // size type has width , height attributes size.height = sar_nrows_integer; // height of size size.width = sar_ncols_integer; extracted_sar_image = cvcreateimageheader(size, ipl_depth_8u, 1); (int row = 0 ; row < size.height ;row++) { memcpy(&extracted_sar_image->imagedata[row*extracted_sar_image->widthstep],&myarray.data()[row*size.width],size.width); }

qt opencv iplimage qbytearray

No comments:

Post a Comment