Ask Your Question
0

Resizing an image

asked 2012-09-03 10:50:43 -0600

chhenning gravatar image

Hi there, sorry for cross posting this question from stackoverflow. But could someone tell me what wrong with the following code?

Mat src = imread( "image.tif" );
Mat dst;
Size s( src.size().width / 10, src.size().height / 10 );
resize( src, dst, s, 0, 0, CV_INTER_AREA );

imwrite("test.tif", dst );

This will give me an assertion:

OpenCV Error: Assertion failed (ssize.area() > 0) in unknown function, file C:\slave\WinInstallerMegaPack\src\opencv\modules\imgproc\src\imgwarp.cpp, line 1432

I'm using OpenCV 2.4 on a Windows 7 machine.

Thanks, Christian

edit retag flag offensive close merge delete

Comments

HI i am facing same problem in android. how did you sort out your problem ?

honestsuccess gravatar imagehonestsuccess ( 2013-11-07 10:28:25 -0600 )edit

3 answers

Sort by ยป oldest newest most voted
3

answered 2012-09-03 15:08:17 -0600

chhenning gravatar image

I could figure it out. The code is correct but I have to switch to the Multi-threaded runtime libs ( /MT ). Even for debug configuration! Usually I use Multi-threaded DLL runtime lib ( /MD ).

In addition I also have to remove the _DEBUG compiler symbol.

I guess it's best to build OpenCV myself.

Thanks, Christian

edit flag offensive delete link more
2

answered 2012-09-03 11:29:54 -0600

Michael Burdinov gravatar image

updated 2012-09-03 11:31:17 -0600

Are you sure that "image.tif" was actually acquired? If not "src" will remain empty and the rest of your functions may not work properly.

edit flag offensive delete link more

Comments

You are correct, the image isn't read. This is strange. I have two versions of OpenCV on my machine. One is from the git reposity ( version 2.4.9 ) and one is the released 2.4.0. When I use 2.4.9 the image is read but the resizing doesn't work. So I tried 2.4., but now the image isn't read and I cannot see why... Any ideas?

chhenning gravatar imagechhenning ( 2012-09-03 12:02:42 -0600 )edit

@chhenning, yor can try to use absolute filepath for image.tif

Victor1234 gravatar imageVictor1234 ( 2012-09-03 14:46:47 -0600 )edit

I'm using an absolute path. My problem is due to the runtime lib config as described above.

chhenning gravatar imagechhenning ( 2012-09-03 16:20:56 -0600 )edit
0

answered 2013-04-22 01:19:08 -0600

carolinenew gravatar image

updated 2013-04-22 01:22:55 -0600

here is an example of resizing image. Imports System.IO Imports System.Drawing.Printing Imports RasterEdge.Imaging Imports RasterEdge.Imaging.Processing

Dim Image As New RasterEdgeImaging()

Private Shared Function ResizeImage() As Image If True Then Dim LoadImage As New Bitmap("C:\1.bmp") Dim newsize As Size = New size(width, height) Dim newsize As e.g.Size = New size(150, 250) End IfEnd Function Image.ResizeImage (@"C:\1.bmp", new size(150,250))

edit flag offensive delete link more

Comments

Here is an OpenCV library forum, and the question is for C++ language. Your answer is for another library, and a different language.

sammy gravatar imagesammy ( 2013-04-22 01:32:19 -0600 )edit

Question Tools

Stats

Asked: 2012-09-03 10:50:43 -0600

Seen: 15,925 times

Last updated: Apr 22 '13