#include "image.h"
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Some of the code are from elsewhere. The PGM routines are taken from
* G. Daivs code.
*
* Mow-Song, Ng 2/9/2002
* [email protected]
* http://www.pesona.mmu.edu.my/~msng
*
* I do not claim copyright to the code, but if you use them or modify them,
* please drop me a mail.
*
*/
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
int SetImage(PIMAGE pimageSrc, unsigned char val)
{
if (pimageSrc->pixel[0] != NULL){
memset(pimageSrc->pixel[0], val, (pimageSrc->xsize) * (pimageSrc->ysize) * sizeof(unsigned char));
return 1;
}
else{
return 0;
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
int ImageDynamicRange(PIMAGE pimage, unsigned char *MaxPixel, unsigned char *MinPixel)
{
unsigned char TempPixel;
int i, j;
*MaxPixel=MIN_GREY;
*MinPixel=MAX_GREY;
if (pimage->pixel[0] != NULL){
for (j=0; j<pimage->ysize; j++){
for (i=0; i<pimage->xsize; i++){
TempPixel=pimage->pixel[j][i];
if (TempPixel > *MaxPixel){
*MaxPixel=TempPixel;
}
if (TempPixel < *MinPixel){
*MinPixel=TempPixel;
}
}
}
return 1;
}
else{
return 0;
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
PIMAGE ReadRawGreyFile(int xsize, int ysize, char *filename)
{
int i;
PIMAGE pimage;
FILE *fp;
pimage = (PIMAGE)malloc(sizeof(IMAGE));
pimage->xsize=xsize;
pimage->ysize=ysize;
/* Allocate memory */
if(!ImageBufferAlloc(pimage)){
free(pimage);
return NULL;
}
/* open the file */
if ((fp=fopen(filename, "rb"))==NULL){
ImageBufferFree(pimage);
free(pimage);
return NULL;
}
i=fread(pimage->pixel[0], sizeof(unsigned char),
(pimage->xsize)*(pimage->ysize), fp);
fclose(fp);
if (i!=(pimage->ysize)*(pimage->xsize)){
ImageBufferFree(pimage);
free(pimage);
return NULL;
}
else{
return pimage;
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
PFIMAGE ReadRawGreyFileToFloat(int xsize, int ysize, char *filename)
{
int i;
PFIMAGE pfimage;
FILE *fp;
unsigned char **temp, *tempLinear;
/* temporary buffer */
temp = Byte_Alloc(ysize , xsize);
tempLinear=temp[0];
if(temp == NULL){
return NULL;
}
/* open the file */
if ((fp=fopen(filename, "rb"))==NULL){
free(temp[0]);
return NULL;
}
/* read the image */
i=fread(temp[0], sizeof(unsigned char), xsize*ysize, fp);
fclose(fp);
if (i!=ysize*xsize){
free(temp[0]);
return NULL;
}
pfimage = (PFIMAGE)malloc(sizeof(FIMAGE));
pfimage->xsize=xsize;
pfimage->ysize=ysize;
/* Allocate memory */
if(!FImageBufferAlloc(pfimage)){
free(pfimage);
free(temp[0]);
return NULL;
}
/* Copy */
for (i=0; i< xsize*ysize; i++){
pfimage->pixelLinear[i]=(double)tempLinear[i];
}
free(temp[0]);
return pfimage;
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
int WriteFloatToRawGreyFile(PFIMAGE pfimage, char *filename)
{
int i;
FILE *fp;
unsigned char **temp, *tempLinear;
temp=Byte_Alloc(pfimage->ysize, pfimage->xsize);
tempLinear=temp[0];
if (temp==NULL){
return 0;
}
if((fp=fopen(filename, "wb"))==NULL){
free(temp[0]);
return 0;
}
/* Copy */
for (i=0; i<pfimage->xsize*pfimage->ysize; i++){
tempLinear[i]=(int)((pfimage->pixelLinear[i]+0.5) < 0.0 ? 0 :
((pfimage->pixelLinear[i]+0.5) > 255.0 ? 255 :
(pfimage->pixelLinear[i]+0.5)));
}
i=fwrite(temp[0], sizeof(unsigned char), (pfimage->ysize)*(pfimage->xsize), fp);
fclose(fp);
free(temp[0]);
if (i!=(pfimage->ysize)*(pfimage->xsize)){
return 0;
}
else{
return i;
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
PLIMAGE ReadRaw32File(int xsize, int ysize, char *filename)
{
int i;
PLIMAGE plimage;
FILE *fp;
plimage = (PLIMAGE)malloc(sizeof(LIMAGE));
plimage->xsize=xsize;
plimage->ysize=ysize;
/* Allocate memory */
if(!LImageBufferAlloc(plimage)){
free(plimage);
return NULL;
}
/* open the file */
if ((fp=fopen(filename, "rb"))==NULL){
LImageBufferFree(plimage);
free(plimage);
return NULL;
}
i=fread(plimage->pixel[0], sizeof(int),
(plimage->xsize)*(plimage->ysize), fp);
fclose(fp);
if (i!=(plimage->ysize)*(plimage->xsize)){
LImageBufferFree(plimage);
free(plimage);
return NULL;
}
else{
return plimage;
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
PFIMAGE ReadRawFloatFile(int xsize, int ysize, char *filename)
{
int i;
PFIMAGE pfimage;
FILE *fp;
pfimage = (PFIMAGE)malloc(sizeof(FIMAGE));
pfimage->xsize=xsize;
pfimage->ysize=ysize;
/* Allocate memory */
if(!FImageBufferAlloc(pfimage)){
free(pfimage);
return NULL;
}
/* open the file */
if ((fp=fopen(filename, "rb"))==NULL){
FImageBufferFree(pfimage);
free(pfimage);
return NULL;
}
i=fread(pfimage->pixel[0], sizeof(double),
(pfimage->xsize)*(pfimage->ysize), fp);
fclose(fp);
if (i!=(pfimage->ysize)*(pfimage->xsize)){
FImageBufferFree(pfimage);
free(pfimage);
return NULL;
}
else{
return pfimage;
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
int WriteRawGreyFile(PIMAGE pimage, char *filename)
{
int i;
FILE *fp;
if((fp=fopen(filename, "wb"))==NULL){
return 0;
}
i=fwrite(pimage->pixel[0], sizeof(unsigned char),
(pimage->ysize)*(pimage->xsize), fp);
fclose(fp);
if (i!=(pimage->ysize)*(pimage->xsize)){
return 0;
}
else{
return i;
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
int WriteRaw32File(PLIMAGE plimage, char *filename)
{
int i;
FILE *fp;
if((fp=fopen(filename, "wb"))==NULL){
return 0;
}
i=fwrite(plimage->pixel[0], sizeof(int),
(plimage->xsize)*(plimage->ysize), fp);
fclose(fp);
if (i!=(plimage->ysize)*(plimage->xsize)){
return 0;
}
else{
return i;
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
int WriteRawFloatFile(PFIMAGE pfimage, char *filename)
{
int i;
FILE *fp;
if((fp=fo
没有合适的资源?快使用搜索试试~ 我知道了~
ezw.rar_EZW
共84个文件
sbr:18个
obj:18个
cpp:17个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 48 浏览量
2022-09-23
09:33:44
上传
评论
收藏 862KB RAR 举报
温馨提示
本文件夹内包含了经典的比较全面的EZW编解码算法,希望大家共同学习
资源推荐
资源详情
资源评论
收起资源包目录
ezw.rar (84个子文件)
ezw
image_bw.h 3KB
wtransform.cpp 17KB
wavelet.h 3KB
image_bw.cpp 14KB
subbandsymbol.h 1KB
wavelet.cpp 19KB
ezw.plg 240B
memchk.h 3KB
mem.cpp 4KB
ezw.ncb 305KB
ezw.opt 52KB
lena5.pgm 64KB
map.cpp 5KB
lena.pgm 64KB
aricacm.cpp 30KB
memchk.cpp 11KB
ezw.cpp 17KB
bitio.h 2KB
bitio.cpp 4KB
mem.h 1KB
filter.h 3KB
lena.cmp 4KB
aricacm.h 10KB
filter.cpp 24KB
wtransform.h 4KB
main.cpp 18KB
spiht.h 17KB
unezw.cpp 14KB
global.h 2KB
image.cpp 36KB
image.h 5KB
map.h 2KB
global.cpp 4KB
ezw.h 4KB
aritcode.h 5KB
Debug
bitio.sbr 0B
ezw.pdb 881KB
filter.sbr 0B
mem.obj 8KB
image.sbr 0B
ezw.sbr 0B
global.obj 11KB
wavelet.sbr 0B
map.sbr 0B
unezw.sbr 0B
ezw.exe 380KB
mem.sbr 0B
global.sbr 0B
image.obj 57KB
spiht.sbr 0B
spiht.obj 53KB
vc60.idb 105KB
ezw.obj 21KB
main.obj 92KB
image_bw.obj 26KB
wtransform.sbr 0B
ezw.bsc 417KB
map.obj 8KB
general.sbr 0B
wavelet.obj 19KB
ezw.pch 247KB
unezw.obj 17KB
general.obj 16KB
filter.obj 23KB
vc60.pdb 60KB
bitio.obj 10KB
ezw.ilk 410KB
image_bw.sbr 0B
aritcode.sbr 0B
subbandsymbol.sbr 0B
wtransform.obj 22KB
memchk.sbr 0B
aricacm.obj 38KB
memchk.obj 9KB
subbandsymbol.obj 8KB
aricacm.sbr 0B
aritcode.obj 24KB
main.sbr 0B
ezw.dsw 531B
ezw.dsp 6KB
aritcode.cpp 11KB
general.h 4KB
general.cpp 6KB
subbandsymbol.cpp 5KB
共 84 条
- 1
资源评论
JonSco
- 粉丝: 72
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功