이미지 정보 가져오기 (IPlImage 구조체 사용)



c++)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
 
void main() {
    IplImage *image;
    uchar *data;
    
    //image load
    image = cvLoadImage("D:/study/colorimage.png", CV_LOAD_IMAGE_UNCHANGED);
 
    data = (uchar*)image->imageData;        //image pixcel data의 pointer
    printf("채널수 : %d\n", image->nChannels);    //픽셀당 채널수
    printf("영상의 원점 : %d\n", image->origin);    //영상의 원점(0 : top-left, 1 : bottom-left)
    printf("영상의 가로크기 : %d\n", image->width);    //영상의 가로크기(단위 : 픽셀)
    printf("영상의 세로크기 : %d\n", image->height);    //영상의 세로크기(단위 : 픽셀)
    printf("가로크기 : %dbytes\n", image->widthStep);//영상의 가로크기(단위 : 바이트) = width * nChannels
    printf("사용 비트수 : %dbits\n", image->depth);     //데이터를 몇 비트를 가지고 표현할 것인가
    printf("영상크기 : %dbytes\n", image->imageSize);//영상의 크기(단위 : 바이트) = width * height * nChannels
    printf("101번 이미지 데이터 : %d\n", data[100]); //픽셀의 이미지 데이터
 
    //image release
    cvReleaseImage(&image);
}
cs



결과



+ Recent posts