图像处理的几个小程序
1.rgb2hsi.exe:将 RGB 空间转换到 HSI 空间
/*
File Name: rgb2hsi.c
Description: convert a bitmap from RGB to HSI
Author: Peng Jun(admin#pengjun.org.cn)
Web Site: http://pengjun.org.cn
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "Bitmap.h"
int main(int argc, char *argv[])
{
Bitmap *bmp = (Bitmap*)malloc(sizeof(Bitmap));
DWORD i = 0, j = 0;
double h = 0.0, s = 0.0, ii = 0.0;
BYTE r = 0, g = 0, b = 0, min = 0;
if( argc != 3 )
{
printf("Usage: rgb2hsi <img_src> <img_dst>");
free(bmp);
return -1;
}
load_bitmap( argv[1], bmp );
if( ISEMPTY( bmp ) || !IS24BITS( bmp ) )
{
free(bmp);
return -1;
}
for( i = 0; i < bmp->height; i++ )
{
for( j = 0; j < bmp->width * 3; j += 3 )
{
b = GET_B( bmp, i, j );
g = GET_G( bmp, i, j );