Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 36 lines (29 sloc) 0.918 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#include "cv.h"

typedef struct {
    int xstart, ystart, xstop, ystop;
} imgdim;

int pxdiff(uchar* px1, uchar* px2) {
    return abs(px1[0] - px2[0]) + abs(px1[1] - px1[1]) + abs(px1[2] - px2[2]);
}

uchar* px_pos(IplImage* img, int x, int y){
    uchar* ptr = (uchar*) (
            img->imageData + y * img->widthStep + img->nChannels * x
            );
    return ptr;
}


imgdim get_dimensions(IplImage* in_img) {
    // returns image dimensions in imgdim struct

    imgdim toret;

    if (in_img->roi) {
        toret.ystart = in_img->roi->yOffset;
        toret.xstart = in_img->roi->xOffset;
        toret.ystop = MIN(toret.ystart + in_img->roi->height, in_img->height);
        toret.xstop = MIN(toret.xstart + in_img->roi->width, in_img->width);
    } else {
        toret.xstart=0;
        toret.ystart=0;
        toret.ystop=in_img->height;
        toret.xstop=in_img->width;
    }
    return toret;
}
Something went wrong with that request. Please try again.