Resize row from Mat [closed]

asked 2013-10-06 13:35:57 -0600

Jorge Pereira gravatar image

updated 2013-10-06 15:37:33 -0600

Moster gravatar image

I'm trying to resize the rows of a ROI Mat, witch is a polygon with different row size, to the half of the cols of the original Mat, and so I thought of run through all the rows of the Roi Mat and resize each one.

for (int j = 0; j < crop.rows; j++)
{
    if(pointPolygonTest( contours[0], Point2f((float)i,(float)j), true) > 0)

    //resize(crop.row(j), crop.row(j), Size(img.rows, img.cols/2), 0, 0, CV_INTER_LINEAR);
}

What am I doing wrong? Thank you!

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-11-22 14:22:48.482475

Comments

Im not even sure if you can apply the resize function on a row, but in the current way you are doing it, it does not make sense. You are actually expanding a row to (img.rows, img.cols/2) which is not 1 single row anymore. If resize on a row even works, it should more looks like this: resize(crop.row(j), crop.row(j), Size(1, img.cols/2), 0, 0, CV_INTER_LINEAR); There is no guarantee that this actually works.

Moster gravatar imageMoster ( 2013-10-06 15:40:51 -0600 )edit

It doesn't... I have this image witch is a Mat with different row size and I want to stretch the rows to make them of constant length.

Jorge Pereira gravatar imageJorge Pereira ( 2013-10-06 15:46:05 -0600 )edit

Btw, Im not sure if the input and output can be the same in resize. Maybe you need a new Mat for the output

Moster gravatar imageMoster ( 2013-10-06 15:46:19 -0600 )edit

Do you want to crop this image or resize it? Thats a difference. If you resize you still have the same image, just in another size. Cropping removes parts that you dont want to have in there anymore.

Moster gravatar imageMoster ( 2013-10-06 15:49:05 -0600 )edit

I already cropped the image, I want to resize the row lenght as the example in the image. I have to perform those modifications (c to d).

Jorge Pereira gravatar imageJorge Pereira ( 2013-10-06 16:06:28 -0600 )edit