What is the use of cvGetRows() function in OpenCV? -
when should use function. can explain me example?
according documentation, itreturns array row or row span. returns rows specified.
i explain of python terminal:
load image in grayscale mode , check width , height.
>>> import cv2.cv cv >>> img = cv.loadimage('approx2.jpg',0) >>> img <iplimage(nchannels=1 width=300 height=300 widthstep=300 )> see, image 300x300 size. below image.

taking sum pixels,
>>> cv.sum(img) (1252271.0, 0.0, 0.0, 0.0) now apply our first function, cv.getrow()
>>> row = cv.getrow(img,150) >>> row <cvmat(type=42424000 8uc1 rows=1 cols=300 step=300 )> >>> cv.sum(row) (14279.0, 0.0, 0.0, 0.0) i took 150th row , took sum of elements in row. see resulting image has height = 1.
now taking function cv.getrows().
>>> rows = cv.getrows(img,0,150) >>> rows <cvmat(type=42424000 8uc1 rows=150 cols=300 step=300 )> >>> cv.sum(rows) (802501.0, 0.0, 0.0, 0.0) i took rows upto 150th. see height 150. check out image below:

now there fourth argument on function delta_row can used increment. select rows increment of step size mentioned, skipping in between. ie if specified, the function extracts every delta_row -th row start_row , (but not including) end_row .
>>> rows = cv.getrows(img,0,300,5) >>> rows <cvmat(type=42420000 8uc1 rows=60 cols=300 step=1500 )> see, height 30 because extracts every 5th row.
result below :

similar case cv.getcol() , cv.getcols().
Comments
Post a Comment