Opencv notes: image size conversion

Source: Internet
Author: User
Opencv notes: image size conversion ArticleSource Address: http://hi.baidu.com/gilbertjuly/blog/item/25e4cd3f08ee733471cf6c82.html
ProgramIf you do not understand the function, please refer to this CHM document, www.opencv.org.cn/index.php/download, with the search function, equivalent to msdnof mfc.
======================================
The second example is the image size Transformation:
# Include
<Cv. h>
# Include
# Include <math. h>
Int
Main (INT argc, char * argv [])
{
Iplimage * src = 0;
Iplimage *
DST = 0;
Double scale = 0.618; // Scaling Factor
Cvsize dst_cvsize;
// Used to store the image size
If
(Argc = 2 & (src = cvloadimage (argv [1],-1 ))! = 0)
{
Dst_cvsize.width = (INT) (SRC-> width * scale );
// Width of the source Image
Dst_cvsize.height = (INT) (SRC-> height * scale );
// Height of the source Image
DST = cvcreateimage (dst_cvsize, Src-> depth, Src-> nchannels );
// Create an image
Cvresize (SRC, DST, cv_inter_linear );
// Implement size conversion
Cvnamedwindow ("src", cv_window_autosize );
Cvnamedwindow ("DST", cv_window_autosize );
Cvshowimage ("src", Src );
Cvshowimage ("DST", DST );
Cvwaitkey (0 );
Cvreleaseimage (& SRC );
Cvreleaseimage (& DST );
Cvdestroywindow ("src ");
Cvdestroywindow ("DST ");
}
Return
0;
}
======================================
The second parameter of cvloadimage is different from the previous one, specifically:
# Define
Cv_load_image_unchanged-1
# Define cv_load_image_grayscale 0
# Define
Cv_load_image_color 1
# Define cv_load_image_anydepth 2
# Define
Cv_load_image_anycolor
4
We can see from the macro definition that different colors and depths of the image. If you want to load the most authentic image, select cv_load_image_anydepth |
Cv_load_image_anycolor.

cvloadimage currently supports the following file formats:
Windows bitmap file-BMP,
Dib;
JPEG file-JPEG, JPG, jpe;
portable network image-PNG;
portable image formats-PBM, PGM, and ppm;

sun rasters-Sr, Ras;
TIFF file-Tiff, Tif;
openexr HDR Image-EXR;

JPEG 2000 image-JP2.
Source Address: http://hi.baidu.com/gilbertjuly/blog/item/25e4cd3f08ee733471cf6c82.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.