BRL-CAD
Image

Files

file  fileformat.c
 
file  color_space.c
 
file  crop.c
 
file  operations.c
 
file  filter.c
 
file  stat.c
 

Data Structures

struct  icv_image
 

Macros

#define ICV_NULL_IMAGE   0X0001
 
#define ICV_SANITIZED   0X0002
 
#define ICV_OPERATIONS_MODE   0x0004
 
#define ICV_UNDEFINED_1   0x0008
 
#define ICV_IMAGE_NULL   ((struct icv_image *)0)
 
#define ICV_CK_IMAGE(_i)   ICV_CKMAG(_i, ICV_IMAGE_MAGIC, "icv_image")
 
#define ICV_IMAGE_INIT(_i)
 
#define ICV_IMAGE_IS_INITIALIZED(_i)   (((struct icv_image *)(_i) != ICV_IMAGE_NULL) && LIKELY((_i)->magic == ICV_IMAGE_MAGIC))
 
#define ICV_IMAGE_VAL_INT(_i)   if (!ICV_IMAGE_IS_INITIALIZED(_i)) return -1
 
#define ICV_IMAGE_VAL_PTR(_i)   if (!ICV_IMAGE_IS_INITIALIZED(_i)) return NULL
 
#define ICV_CONV_8BIT(data)   ((double)(data))/255.0
 
#define icv_rgb2gray_ntsc(_a)   icv_rgb2gray(_a, ICV_COLOR_RGB, 0.30, 0.59, 0.11)
 
#define icv_rgb2gray_crt(_a)   icv_rgb2gray(_a, ICV_COLOR_RGB, 0.26, 0.66, 0.08)
 

Typedefs

typedef struct icv_image icv_image_t
 

Enumerations

enum  ICV_COLOR_SPACE { ICV_COLOR_SPACE_RGB, ICV_COLOR_SPACE_GRAY }
 
enum  ICV_DATA { ICV_DATA_DOUBLE, ICV_DATA_UCHAR }
 
enum  ICV_COLOR {
  ICV_COLOR_RGB, ICV_COLOR_R, ICV_COLOR_G, ICV_COLOR_B,
  ICV_COLOR_RG, ICV_COLOR_RB, ICV_COLOR_BG
}
 
enum  ICV_FILTER {
  ICV_FILTER_LOW_PASS, ICV_FILTER_LAPLACIAN, ICV_FILTER_HORIZONTAL_GRAD, ICV_FILTER_VERTICAL_GRAD,
  ICV_FILTER_HIGH_PASS, ICV_FILTER_NULL, ICV_FILTER_BOXCAR_AVERAGE
}
 
enum  ICV_FILTER3 {
  ICV_FILTER3_LOW_PASS, ICV_FILTER3_HIGH_PASS, ICV_FILTER3_BOXCAR_AVERAGE, ICV_FILTER3_ANIMATION_SMEAR,
  ICV_FILTER3_NULL
}
 
enum  ICV_RESIZE_METHOD { ICV_RESIZE_UNDERSAMPLE, ICV_RESIZE_SHRINK, ICV_RESIZE_NINTERP, ICV_RESIZE_BINTERP }
 

Functions

ICV_IMAGE_FORMAT icv_guess_file_format (const char *filename, char *trimmedname)
 
icv_image_ticv_create (int width, int height, ICV_COLOR_SPACE color_space)
 
int icv_writeline (icv_image_t *bif, int y, void *data, ICV_DATA type)
 
int icv_writepixel (icv_image_t *bif, int x, int y, double *data)
 
int icv_write (icv_image_t *bif, const char *filename, ICV_IMAGE_FORMAT format)
 
icv_image_ticv_read (const char *filename, int format, int width, int height)
 
icv_image_ticv_zero (icv_image_t *bif)
 
int icv_destroy (icv_image_t *bif)
 
int icv_gray2rgb (icv_image_t *img)
 
int icv_rgb2gray (icv_image_t *img, ICV_COLOR color, double rweight, double gweight, double bweight)
 
int icv_rect (icv_image_t *img, int xorig, int yorig, int xnum, int ynum)
 
int icv_crop (icv_image_t *img, int ulx, int uly, int urx, int ury, int lrx, int lry, int llx, int lly, unsigned int ynum, unsigned int xnum)
 
int icv_sanitize (icv_image_t *img)
 
int icv_add_val (icv_image_t *img, double val)
 
int icv_multiply_val (icv_image_t *img, double val)
 
int icv_divide_val (icv_image_t *img, double val)
 
int icv_pow_val (icv_image_t *img, double val)
 
icv_image_ticv_add (icv_image_t *img1, icv_image_t *img2)
 
icv_image_ticv_sub (icv_image_t *img1, icv_image_t *img2)
 
icv_image_ticv_multiply (icv_image_t *img1, icv_image_t *img2)
 
icv_image_ticv_divide (icv_image_t *img1, icv_image_t *img2)
 
int icv_saturate (icv_image_t *img, double sat)
 
int icv_filter (icv_image_t *img, ICV_FILTER filter_type)
 
icv_image_ticv_filter3 (icv_image_t *old_img, icv_image_t *curr_img, icv_image_t *new_img, ICV_FILTER3 filter_type)
 
int icv_fade (icv_image_t *img, double fraction)
 
size_t ** icv_hist (icv_image_t *img, int n_bins)
 
double * icv_min (icv_image_t *img)
 
double * icv_mean (icv_image_t *img)
 
double * icv_sum (icv_image_t *img)
 
double * icv_max (icv_image_t *img)
 
int * icv_mode (icv_image_t *img, size_t **bins, int n_bins)
 
int * icv_median (icv_image_t *img, size_t **bins, int n_bins)
 
double * icv_skew (icv_image_t *img, size_t **bins, int n_bins)
 
double * icv_var (icv_image_t *img, size_t **bins, int n_bins)
 
int icv_resize (icv_image_t *bif, ICV_RESIZE_METHOD method, unsigned int out_width, unsigned int out_height, unsigned int factor)
 

Detailed Description

Macro Definition Documentation

#define ICV_NULL_IMAGE   0X0001

Definition at line 81 of file icv.h.

#define ICV_SANITIZED   0X0002

Definition at line 82 of file icv.h.

Referenced by icv_add_val(), icv_divide_val(), icv_multiply_val(), icv_pow_val(), and icv_sanitize().

#define ICV_OPERATIONS_MODE   0x0004

Definition at line 83 of file icv.h.

Referenced by icv_add_val(), icv_divide_val(), icv_multiply_val(), and icv_pow_val().

#define ICV_UNDEFINED_1   0x0008

Definition at line 84 of file icv.h.

#define ICV_IMAGE_NULL   ((struct icv_image *)0)

Definition at line 97 of file icv.h.

#define ICV_CK_IMAGE (   _i)    ICV_CKMAG(_i, ICV_IMAGE_MAGIC, "icv_image")

asserts the integrity of a icv_image_file struct.

Definition at line 102 of file icv.h.

#define ICV_IMAGE_INIT (   _i)
Value:
{ \
(_i)->width = (_i)->height = (_i)->channels = (_i)->alpha_channel = 0; \
(_i)->gamma_corr = 0.0; \
(_i)->data = NULL; \
}
ustring width
COMPLEX data[64]
Definition: fftest.c:34
oldeumate l2 magic
Definition: nmg_mod.c:3843
#define ICV_IMAGE_MAGIC
Definition: magic.h:216

initializes a icv_image_file struct without allocating any memory.

Definition at line 107 of file icv.h.

Referenced by bw_read(), pix_read(), and ppm_read().

#define ICV_IMAGE_IS_INITIALIZED (   _i)    (((struct icv_image *)(_i) != ICV_IMAGE_NULL) && LIKELY((_i)->magic == ICV_IMAGE_MAGIC))

returns truthfully whether a icv_image_file has been initialized.

Definition at line 117 of file icv.h.

#define ICV_IMAGE_VAL_INT (   _i)    if (!ICV_IMAGE_IS_INITIALIZED(_i)) return -1
#define ICV_IMAGE_VAL_PTR (   _i)    if (!ICV_IMAGE_IS_INITIALIZED(_i)) return NULL

Validates input icv_struct, if failure (in validation) returns NULL

Definition at line 128 of file icv.h.

Referenced by data2uchar(), icv_add(), icv_divide(), icv_filter3(), icv_hist(), icv_max(), icv_mean(), icv_median(), icv_min(), icv_mode(), icv_multiply(), icv_skew(), icv_sub(), icv_sum(), icv_var(), and icv_zero().

#define ICV_CONV_8BIT (   data)    ((double)(data))/255.0

Converts to double (icv data) type from unsigned char(8bit).

Definition at line 135 of file icv.h.

Referenced by icv_writeline(), and uchar2double().

#define icv_rgb2gray_ntsc (   _a)    icv_rgb2gray(_a, ICV_COLOR_RGB, 0.30, 0.59, 0.11)

converts image to single channel image by combining three weights based on NTSC primaries and 6500 white.

Definition at line 273 of file icv.h.

Referenced by bw_write().

#define icv_rgb2gray_crt (   _a)    icv_rgb2gray(_a, ICV_COLOR_RGB, 0.26, 0.66, 0.08)

converts image to single channel image by combining three weights based on CRT phosphor and D6500 white.

Definition at line 279 of file icv.h.

Typedef Documentation

typedef struct icv_image icv_image_t

Definition at line 96 of file icv.h.

Enumeration Type Documentation

Enumerator
ICV_COLOR_SPACE_RGB 
ICV_COLOR_SPACE_GRAY 

Definition at line 69 of file icv.h.

enum ICV_DATA
Enumerator
ICV_DATA_DOUBLE 
ICV_DATA_UCHAR 

Definition at line 75 of file icv.h.

enum ICV_COLOR
Enumerator
ICV_COLOR_RGB 
ICV_COLOR_R 
ICV_COLOR_G 
ICV_COLOR_B 
ICV_COLOR_RG 
ICV_COLOR_RB 
ICV_COLOR_BG 

Definition at line 259 of file icv.h.

enum ICV_FILTER
Enumerator
ICV_FILTER_LOW_PASS 
ICV_FILTER_LAPLACIAN 
ICV_FILTER_HORIZONTAL_GRAD 
ICV_FILTER_VERTICAL_GRAD 
ICV_FILTER_HIGH_PASS 
ICV_FILTER_NULL 
ICV_FILTER_BOXCAR_AVERAGE 

Definition at line 485 of file icv.h.

Enumerator
ICV_FILTER3_LOW_PASS 
ICV_FILTER3_HIGH_PASS 
ICV_FILTER3_BOXCAR_AVERAGE 
ICV_FILTER3_ANIMATION_SMEAR 
ICV_FILTER3_NULL 

Definition at line 495 of file icv.h.

Enumerator
ICV_RESIZE_UNDERSAMPLE 
ICV_RESIZE_SHRINK 
ICV_RESIZE_NINTERP 
ICV_RESIZE_BINTERP 

Definition at line 675 of file icv.h.

Function Documentation

ICV_IMAGE_FORMAT icv_guess_file_format ( const char *  filename,
char *  trimmedname 
)

Finds the Image format based on heuristics depending on the file name.

Parameters
filenameFilename of the image whose format is to be know
trimmednameBuffer for storing filename after removing extensions
Returns
File Format

Definition at line 82 of file fileformat.c.

References bu_strlcpy, CMP, and ICV_IMAGE_UNKNOWN.

Referenced by icv_write().

icv_image_t* icv_create ( int  width,
int  height,
ICV_COLOR_SPACE  color_space 
)

This function allocates memory for an image and returns the resultant image.

Parameters
widthWidth of the image to be created
heightHeight of the image to be created
color_spaceColor space of the image (RGB, grayscale)
Returns
Image structure with allocated space and zeroed data array

Definition at line 276 of file fileformat.c.

References icv_image::alpha_channel, BU_ALLOC, bu_exit(), bu_malloc(), icv_image::channels, icv_image::color_space, icv_image::data, icv_image::height, ICV_COLOR_SPACE_GRAY, ICV_COLOR_SPACE_RGB, ICV_IMAGE_MAGIC, icv_zero(), icv_image::magic, icv_image::width, and OSL::Strings::width.

Referenced by dpix_read(), ged_screen_grab(), icv_add(), icv_divide(), icv_filter3(), icv_multiply(), and icv_sub().

Here is the call graph for this function:

int icv_writeline ( icv_image_t bif,
int  y,
void *  data,
ICV_DATA  type 
)

Write an image line to the data of ICV struct. Can handle unsigned char buffers.

Note : This function requires memory allocation for ICV_UCHAR_DATA, which in turn acquires BU_SEM_SYSCALL semaphore.

Parameters
bifICV struct where data is to be written
yIndex of the line at which data is to be written. 0 for the first line Line Data to be written Type of data, e.g., uint8 data specify ICV_DATA_UCHAR or 1
Returns
on success 0, on failure -1

Definition at line 219 of file fileformat.c.

References icv_image::channels, icv_image::data, icv_image::height, ICV_CONV_8BIT, ICV_DATA_UCHAR, ICV_IMAGE_VAL_INT, if(), and icv_image::width.

Referenced by ged_screen_grab().

Here is the call graph for this function:

int icv_writepixel ( icv_image_t bif,
int  x,
int  y,
double *  data 
)

Writes a pixel to the specified coordinates in the data of ICV struct.

Parameters
bifICV struct where data is to be written
xx-dir coordinate of the pixel
yy-dir coordinate of the pixel. (0,0) coordinate is taken as bottom left Data to be written
Returns
on success 0, on failure -1

Definition at line 252 of file fileformat.c.

References icv_image::channels, icv_image::data, icv_image::height, ICV_IMAGE_VAL_INT, and icv_image::width.

int icv_write ( icv_image_t bif,
const char *  filename,
ICV_IMAGE_FORMAT  format 
)

Saves Image to a file or streams to stdout in respective format

To stream it to stdout pass NULL pointer for filename.

Parameters
bifImage structure of file.
filenameFilename of the file to be written.
formatSpecific format of the file to be written.
Returns
on success 0, on failure -1 with log messages.

Definition at line 186 of file fileformat.c.

References bu_log(), bw_write(), dpix_write(), icv_guess_file_format(), ICV_IMAGE_AUTO, ICV_IMAGE_BW, ICV_IMAGE_DPIX, ICV_IMAGE_PIX, ICV_IMAGE_PNG, ICV_IMAGE_PPM, ICV_IMAGE_VAL_INT, pix_write(), png_write(), and ppm_write().

Referenced by ged_screen_grab(), and main().

Here is the call graph for this function:

icv_image_t* icv_read ( const char *  filename,
int  format,
int  width,
int  height 
)

Load a file into an ICV struct. For most formats, this will be called with format=ICV_IMAGE_AUTO.

The data is packed in icv_image struct in double format with varied channels as per the specification of image to be loaded.

To read stream from stdin pass NULL pointer for filename.

In case of bw and pix image if size is unknown pass 0 for width and height. This will read the image till EOF is reached. The image size of the output image will be : height = 1; width = size; where size = total bytes read

Parameters
filenameFile to read
hint_formatProbable format of the file, typically ICV_IMAGE_AUTO
hint_widthWidth when passed as parameter from calling program.
hint_heightHeight when passed as parameter from calling program.
Returns
A newly allocated struct holding the loaded image info.

Definition at line 162 of file fileformat.c.

References bu_log(), bw_read(), dpix_read(), ICV_IMAGE_AUTO, ICV_IMAGE_BW, ICV_IMAGE_DPIX, ICV_IMAGE_PIX, ICV_IMAGE_PPM, pix_read(), and ppm_read().

Referenced by main().

Here is the call graph for this function:

icv_image_t* icv_zero ( icv_image_t bif)

This function zeroes all the data entries of an image

Parameters
imgImage Structure

Definition at line 304 of file fileformat.c.

References icv_image::channels, data, icv_image::data, icv_image::height, ICV_IMAGE_VAL_PTR, and icv_image::width.

Referenced by icv_create().

int icv_destroy ( icv_image_t bif)

This function frees the allocated memory for a ICV Structure and data.

Definition at line 321 of file fileformat.c.

References bu_free(), icv_image::data, and ICV_IMAGE_VAL_INT.

Referenced by dpix_read(), ged_screen_grab(), and main().

Here is the call graph for this function:

int icv_gray2rgb ( icv_image_t img)

Converts a single channel image to three channel image. Replicates the pixel as done by bw-pix utility returns a three channel image. If a three channel image is passed, this function returns the same image.

Definition at line 37 of file color_space.c.

References bu_free(), bu_log(), bu_malloc(), icv_image::channels, icv_image::color_space, icv_image::data, icv_image::height, ICV_COLOR_SPACE_GRAY, ICV_COLOR_SPACE_RGB, ICV_IMAGE_VAL_INT, and icv_image::width.

Referenced by dpix_write(), pix_write(), and ppm_write().

Here is the call graph for this function:

int icv_rgb2gray ( icv_image_t img,
ICV_COLOR  color,
double  rweight,
double  gweight,
double  bweight 
)

converts a three channel rgb image to single channel gray-image. This function will combine or select planes of the image based on the input arguments.

A normal calling of this functions is as follows: icv_image_rgb2gray(bif, 0, 0, 0, 0); where bif is the rgb image to be converted.

Parameters
colorChooses color planes to be selected for combination. This function will need color to be specified from ICV_COLOR_R ICV_COLOR_G ICV_COLOR_B ICV_COLOR_RG ICV_COLOR_RB ICV_COLOR_BG ICV_COLOR_RGB
rweightWeight for r-plane
gweightWeight for g-plane
bweightWeight for b-plane
Returns
0 on success; on failure return 1

User can specify weights in the arguments, for the selected color planes. If 0 weight is chosen this utility assigns equal weights.

Definition at line 75 of file color_space.c.

References bu_free(), bu_log(), bu_malloc(), icv_image::channels, icv_image::color_space, icv_image::data, icv_image::height, ICV_COLOR_B, ICV_COLOR_BG, ICV_COLOR_G, ICV_COLOR_R, ICV_COLOR_RB, ICV_COLOR_RG, ICV_COLOR_RGB, ICV_COLOR_SPACE_GRAY, ICV_COLOR_SPACE_RGB, ICV_IMAGE_VAL_INT, out, icv_image::width, and ZERO.

Here is the call graph for this function:

int icv_rect ( icv_image_t img,
int  xorig,
int  yorig,
int  xnum,
int  ynum 
)

This function crops an input image. Note : (0,0) corresponds to the Bottom Left of an Image.

Parameters
imgInput image struct to be cropped.
xorigX-Coordinate of offset of image to be extracted from.
yorigY-Coordinate of offset of image to be extracted from.
xnumLength of the output image to be extracted from input data in horizontal direction.
ynumLength of the output image to be extracted from input data in vertical direction.
Returns
0 on success.

<

Definition at line 32 of file crop.c.

References bu_exit(), bu_free(), bu_malloc(), icv_image::channels, icv_image::data, icv_image::height, ICV_IMAGE_VAL_INT, and icv_image::width.

Referenced by main().

Here is the call graph for this function:

int icv_crop ( icv_image_t img,
int  ulx,
int  uly,
int  urx,
int  ury,
int  lrx,
int  lry,
int  llx,
int  lly,
unsigned int  ynum,
unsigned int  xnum 
)

This function crops an input image.

This can do a screwed cropping, i.e. given any four points of quadrilateral in an image, map it to a rectangle of xnumXynum dimension.

   (ulx,uly)         (urx,ury)
        __________________
       /                 |
      /                  |
     /                   |
    /                    |
   /                     |
  /______________________|
(llx,lly)             (lrx,lry)
Returns
0 on success; on failure -1; and logs the error message.

Definition at line 81 of file crop.c.

References bu_free(), bu_malloc(), icv_image::channels, data, icv_image::data, icv_image::height, ICV_IMAGE_VAL_INT, and icv_image::width.

Referenced by main().

Here is the call graph for this function:

int icv_sanitize ( icv_image_t img)

This function sanitizes the image.

It forces the image pixels to be in the prescribed range.

All the pixels higher than the max range are set to MAX (1.0). All the pixels lower than the min range are set to MIN (0.0).

Note if an image(bif) is sanitized then, (bif->flags&&ICV_SANITIZED) is true.

Definition at line 38 of file operations.c.

References icv_image::channels, data, icv_image::data, icv_image::flags, icv_image::height, ICV_IMAGE_VAL_INT, ICV_SANITIZED, and icv_image::width.

Referenced by icv_add(), icv_add_val(), icv_divide(), icv_divide_val(), icv_multiply(), icv_multiply_val(), icv_pow_val(), icv_saturate(), and icv_sub().

int icv_add_val ( icv_image_t img,
double  val 
)

This adds a constant value to all the pixels of the image. Also if the flag ICV_OPERATIONS_MODE is set this doesn't sanitize the image.

Note to set the flag for a bif (icv_image struct); bif->flags |= ICV_OPERATIONS_MODE;

Definition at line 57 of file operations.c.

References icv_image::channels, data, icv_image::data, icv_image::flags, icv_image::height, ICV_IMAGE_VAL_INT, ICV_OPERATIONS_MODE, icv_sanitize(), ICV_SANITIZED, and icv_image::width.

Here is the call graph for this function:

int icv_multiply_val ( icv_image_t img,
double  val 
)

This multiplies all the pixels of the image with a constant Value. Also if the flag ICV_OPERATIONS_MODE is set this doesn't sanitize the image.

Definition at line 79 of file operations.c.

References icv_image::channels, data, icv_image::data, icv_image::flags, icv_image::height, ICV_IMAGE_VAL_INT, ICV_OPERATIONS_MODE, icv_sanitize(), ICV_SANITIZED, and icv_image::width.

Here is the call graph for this function:

int icv_divide_val ( icv_image_t img,
double  val 
)

This divides all the pixels of the image with a constant Value. Also if the flag ICV_OPERATIONS_MODE is set this doesn't sanitize the image.

Definition at line 100 of file operations.c.

References icv_image::channels, data, icv_image::data, icv_image::flags, icv_image::height, ICV_IMAGE_VAL_INT, ICV_OPERATIONS_MODE, icv_sanitize(), ICV_SANITIZED, and icv_image::width.

Here is the call graph for this function:

int icv_pow_val ( icv_image_t img,
double  val 
)

This raises all the pixels of the image to a constant exponential power. Also if the flag ICV_OPERATIONS_MODE is set this doesn't sanitize the image.

Definition at line 124 of file operations.c.

References icv_image::channels, data, icv_image::data, icv_image::flags, icv_image::height, ICV_IMAGE_VAL_INT, ICV_OPERATIONS_MODE, icv_sanitize(), ICV_SANITIZED, and icv_image::width.

Here is the call graph for this function:

icv_image_t* icv_add ( icv_image_t img1,
icv_image_t img2 
)

This routine adds pixel value of one image to pixel value of other pixel and inserts in the same index of the output image.

Also it sanitizes the image.

Definition at line 146 of file operations.c.

References bu_log(), icv_image::channels, icv_image::color_space, icv_image::data, icv_image::height, icv_create(), ICV_IMAGE_VAL_PTR, icv_sanitize(), and icv_image::width.

Referenced by main().

Here is the call graph for this function:

icv_image_t* icv_sub ( icv_image_t img1,
icv_image_t img2 
)

This routine subtracts pixel value of one image from pixel value of other pixel and inserts the result at the same index of the output image.

Also it sanitizes the image.

Parameters
img1First Image.
img2Second Image.
Returns
New icv_image (img1 - img2)

Definition at line 175 of file operations.c.

References bu_log(), icv_image::channels, icv_image::color_space, icv_image::data, icv_image::height, icv_create(), ICV_IMAGE_VAL_PTR, icv_sanitize(), and icv_image::width.

Referenced by main().

Here is the call graph for this function:

icv_image_t* icv_multiply ( icv_image_t img1,
icv_image_t img2 
)

This routine multiplies pixel value of one image to pixel value of other pixel and inserts the result at the same index of the output image.

Also it sanitizes the image.

Parameters
img1First Image.
img2Second Image.
Returns
New icv_image (img1 * img2)

Definition at line 204 of file operations.c.

References bu_log(), icv_image::channels, icv_image::color_space, icv_image::data, icv_image::height, icv_create(), ICV_IMAGE_VAL_PTR, icv_sanitize(), and icv_image::width.

Referenced by main().

Here is the call graph for this function:

icv_image_t* icv_divide ( icv_image_t img1,
icv_image_t img2 
)

This routine divides pixel value of one image from pixel value of other pixel and inserts the result at the same index of the output image.

Also it sanitizes the image.

Parameters
img1First Image.
img2Second Image.
Returns
New icv_image (img1 / img2)

Definition at line 234 of file operations.c.

References bu_log(), icv_image::channels, icv_image::color_space, icv_image::data, icv_image::height, icv_create(), ICV_IMAGE_VAL_PTR, icv_sanitize(), and icv_image::width.

Referenced by main().

Here is the call graph for this function:

int icv_saturate ( icv_image_t img,
double  sat 
)

Change the saturation of image pixels. If sat is set to 0.0 the result will be monochromatic; if sat is made 1.0, the color will not change; if sat is made greater than 1.0, the amount of color is increased.

Parameters
imgRGB Image to be saturated.
satSaturation value.

Definition at line 263 of file operations.c.

References bu_log(), icv_image::color_space, data, icv_image::data, icv_image::height, ICV_COLOR_SPACE_RGB, ICV_IMAGE_VAL_INT, icv_sanitize(), and icv_image::width.

Referenced by main().

Here is the call graph for this function:

int icv_filter ( icv_image_t img,
ICV_FILTER  filter_type 
)

Filters an image with the specified filter type. Basically convolves kernel with the image. Does zero_padding for outbound pixels.

Parameters
imgImage to be filtered.
filter_typeType of filter to be used.

< index is the index of the pixel in out image and n_index corresponds to the nearby pixel in input image

Definition at line 168 of file filter.c.

References bu_free(), bu_malloc(), icv_image::channels, icv_image::data, get_kernel(), icv_image::height, ICV_IMAGE_VAL_INT, KERN_DEFAULT, and icv_image::width.

Referenced by main().

Here is the call graph for this function:

icv_image_t* icv_filter3 ( icv_image_t old_img,
icv_image_t curr_img,
icv_image_t new_img,
ICV_FILTER3  filter_type 
)

Filters a set of three image with the specified filter type. Does zero_padding for outbound pixels. Finds the resultant pixel with the help of neighboring pixels in all the three images.

Returns
Resultant image.

< index is the index of the pixel in out image and n_index corresponds to the nearby pixel in input image

Definition at line 244 of file filter.c.

References bu_log(), bu_malloc(), icv_image::channels, icv_image::color_space, icv_image::data, get_kernel3(), icv_image::height, icv_create(), ICV_IMAGE_VAL_PTR, KERN_DEFAULT, s, and icv_image::width.

Here is the call graph for this function:

int icv_fade ( icv_image_t img,
double  fraction 
)

icv_fade will darken a pix by a certain fraction.

Fades an image in place.

Parameters
imgICV Image to be faded.
fractionshould be between 0 to 1. Amount by which the image is needed to faded.

Definition at line 326 of file filter.c.

References bu_log(), icv_image::channels, data, icv_image::data, icv_image::height, ICV_IMAGE_VAL_INT, and icv_image::width.

Referenced by main().

Here is the call graph for this function:

size_t** icv_hist ( icv_image_t img,
int  n_bins 
)

This function calculates the histogram of different channels separately.

Parameters
imgImage of which histogram is to found.
n_binsnumber of bins required.
Returns
Histogram of size_t type array. This 2-dimension array is of size c X n_bins where c is the channels in the image.

Definition at line 49 of file stat.c.

References icv_image::channels, data, icv_image::data, icv_image::height, ICV_IMAGE_VAL_PTR, icv_init_bins(), and icv_image::width.

Here is the call graph for this function:

double* icv_min ( icv_image_t img)

Finds the minimum value in each channel of the image.

Returns
a double array of size channels. Each element contains min value of the channel.

e.g. min = icv_min(bif); min[0] gives the minimum value of all the pixels in first bin. and so on.

< An array of size channels.

Definition at line 147 of file stat.c.

References bu_malloc(), icv_image::channels, data, icv_image::data, icv_image::height, ICV_IMAGE_VAL_PTR, and icv_image::width.

Here is the call graph for this function:

double* icv_mean ( icv_image_t img)

Finds the average value in each channel of the image.

Returns
a double array of size channels. Each elements contains average value of the channel.

e.g. mean = icv_mean(bif); mean[0] gives the average value of all the pixels in first channel and so on.

< receives sum from icv_image_sum

Definition at line 128 of file stat.c.

References icv_image::channels, icv_image::height, ICV_IMAGE_VAL_PTR, icv_sum(), and icv_image::width.

Referenced by icv_skew(), and icv_var().

Here is the call graph for this function:

double* icv_sum ( icv_image_t img)

Finds the sum of all the pixel values for each channel of the image

Returns
a double array of size channels. Each element contains sum value of the channel.

e.g. sum = icv_sum(bif); sum[0] gives the sum of all the pixels in first channel and so on.

< An array of size channels.

Definition at line 101 of file stat.c.

References bu_malloc(), icv_image::channels, data, icv_image::data, icv_image::height, ICV_IMAGE_VAL_PTR, and icv_image::width.

Referenced by icv_mean(), and icv_median().

Here is the call graph for this function:

double* icv_max ( icv_image_t img)

Finds the max value in each channel of the image.

Returns
a double array of size channels. Each element contains max value of the channel.

e.g. max = icv_max(bif); max[0] gives the maximum value of all the pixels in first bin. and so on.

< An array of size channels.

Definition at line 75 of file stat.c.

References bu_malloc(), icv_image::channels, data, icv_image::data, icv_image::height, ICV_IMAGE_VAL_PTR, and icv_image::width.

Here is the call graph for this function:

int* icv_mode ( icv_image_t img,
size_t **  bins,
int  n_bins 
)

Calculates mode of the values of each channel. Mode value are calculated for quantified data which is sent as bins(histogram Information). For any image mode is a 'c' length array where c is the number of channels.

To calculate the mode of an icv_image, a default call is as follows icv_mode(img, icv_hist(img, n_bins), n_bins);

This call first calculates the histogram of the image. then finds the mode values from histogram of each channel.

Definition at line 267 of file stat.c.

References bu_malloc(), icv_image::channels, and ICV_IMAGE_VAL_PTR.

Here is the call graph for this function:

int* icv_median ( icv_image_t img,
size_t **  bins,
int  n_bins 
)

Calculates median of the values of each channel. Median value are calculated for quantified data which is sent as bins(histogram information). For any image mode is a 'c' length array, where c is the number of channels.

To calculate the median of an icv_image, a default call is as follows : icv_median(img, icv_hist(img, n_bins), n_bins);

This call first calculates the histogram of the image. then finds the mode values from histogram of each channel.

Definition at line 236 of file stat.c.

References bu_free(), bu_malloc(), icv_image::channels, ICV_IMAGE_VAL_PTR, and icv_sum().

Here is the call graph for this function:

double* icv_skew ( icv_image_t img,
size_t **  bins,
int  n_bins 
)

Calculates the skewness in data.

To calculate the skewness in an icv_image, a default call is as follows : icv_skew(img, icv_hist(img, n_bins), n_bins);

Returns
c length double array where c is the number of channels in the img

Definition at line 205 of file stat.c.

References bu_malloc(), icv_image::channels, icv_image::height, ICV_IMAGE_VAL_PTR, icv_mean(), and icv_image::width.

Here is the call graph for this function:

double* icv_var ( icv_image_t img,
size_t **  bins,
int  n_bins 
)

Calculates the variance in data.

To calculate the variance in an icv_image, a default call is as follows : icv_variance(img, icv_hist(img, n_bins), n_bins);

Returns
c length double array where c is the number of channels in the img

Definition at line 174 of file stat.c.

References bu_malloc(), icv_image::channels, icv_image::height, ICV_IMAGE_VAL_PTR, icv_mean(), and icv_image::width.

Here is the call graph for this function:

int icv_resize ( icv_image_t bif,
ICV_RESIZE_METHOD  method,
unsigned int  out_width,
unsigned int  out_height,
unsigned int  factor 
)

This function resizes the given input image. Mode of usage: a) ICV_RESIZE_UNDERSAMPLE : This method undersamples the said image e.g. icv_resize(bif, ICV_RESIZE_UNDERSAMPLE, 0, 0, 2); undersamples the image with a factor of 2.

b) ICV_RESIZE_SHRINK : This Shrinks the image, keeping the light energy per square area as constant. e.g. icv_resize(bif, ICV_RESIZE_SHRINK,0,0,2); shrinks the image with a factor of 2.

c) ICV_RESIZE_NINTERP : This interpolates using nearest neighbor method. e.g. icv_resize(bif, ICV_RESIZE_NINTERP,1024,1024,0); interpolates the output image to have the size of 1024X1024.

d) ICV_RESIZE_BINTERP : This interpolates using bilinear Interpolation Method. e.g. icv_resize(bif, ICV_RESIZE_BINTERP,1024,1024,0); interpolates the output image to have the size of 1024X1024.

resizes the image inplace.

Parameters
bifImage (packed in icv_image struct)
methodOne of the modes.
out_widthOut Width.
out_heightOut Height.
factorInteger type data representing the factor to be shrunken
Returns
0 on success and -1 on failure.

Definition at line 213 of file size.c.

References binterp(), bu_log(), ICV_IMAGE_VAL_INT, ICV_RESIZE_BINTERP, ICV_RESIZE_NINTERP, ICV_RESIZE_SHRINK, ICV_RESIZE_UNDERSAMPLE, ninterp(), shrink_image(), and under_sample().

Referenced by main().

Here is the call graph for this function: