Skip to content

Commit

Permalink
version 0.3.0-rc7
Browse files Browse the repository at this point in the history
continue to fine-tune the nhw_kernel weights
  • Loading branch information
rcanut committed Jan 5, 2024
1 parent af5cf2a commit 1cc8974
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 22 deletions.
57 changes: 39 additions & 18 deletions encoder/image_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
****************************************************************************
* NHW Image Codec *
* file: image_processing.c *
* version: 0.3.0-rc6 *
* last update: $ 12282023 nhw exp $ *
* version: 0.3.0-rc7 *
* last update: $ 01052024 nhw exp $ *
* *
****************************************************************************
****************************************************************************
Expand All @@ -12,7 +12,7 @@
* remark: -image processing set *
***************************************************************************/

/* Copyright (C) 2007-2023 NHW Project
/* Copyright (C) 2007-2024 NHW Project
Written by Raphael Canut - nhwcodec_at_gmail.com */
/*
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -557,7 +557,7 @@ void im_recons_wavelet_band(image_buffer *im)

void pre_processing(image_buffer *im)
{
int i,j,scan,res,res2,res3,count,e=0,f=0,a=0,sharpness=0,sharpn2=0,n1,t,t1,t2,t3,t4;
int i,j,scan,res,res2,res3,count,e=0,f=0,a=0,sharpness=0,sharpn2=0,n1,t,t1,t2,t3,t4,t5;
short *nhw_process, *nhw_kernel;
char lower_quality_setting_on, *nhw_sharp_on;

Expand Down Expand Up @@ -597,7 +597,7 @@ void pre_processing(image_buffer *im)
else if (im->setup->quality_setting==LOW19) n1=60;


for (i=(2*IM_DIM),res3=0,a=0,t1=0,t2=0,t3=0,t4=0;i<((4*IM_SIZE)-(2*IM_DIM));i+=(2*IM_DIM))
for (i=(2*IM_DIM),res3=0,a=0,t1=0,t2=0,t3=0,t4=0,t5=0;i<((4*IM_SIZE)-(2*IM_DIM));i+=(2*IM_DIM))
{
for (scan=i+1,j=1;j<((2*IM_DIM)-1);j++,scan++)
{
Expand All @@ -623,21 +623,10 @@ void pre_processing(image_buffer *im)
if (abs(res)<=sharpn2 && abs(res2)>sharpn2 && abs(res2)<=(sharpn2+20) && im->setup->quality_setting<=LOW4)
{
if (j>1 && abs(nhw_kernel[scan-1])<=(sharpness>>1)) res3 = 0;
else if (j>1 && abs(nhw_kernel[scan-1])== -(sharpn2+21))
{
if (!t3)
{
res3 = 0;
if (!t1) t1 = 1;

t3 = 1;
}
else t3 = 0;
}

if (!res3)
{
nhw_kernel[scan] = - (sharpn2+21);
nhw_kernel[scan] = 20000; // - (sharpn2+21);

res3 = 1;
}
Expand Down Expand Up @@ -672,7 +661,7 @@ void pre_processing(image_buffer *im)
if (res<=sharpn2 && res2>sharpn2 && res2<=(sharpn2+20) && im->setup->quality_setting<=LOW4)
{
if (j>1 && abs(nhw_kernel[scan-1])<=(sharpness>>1)) a = 0;
else if (j>1 && abs(nhw_kernel[scan-1])==(sharpn2+21))
else if (j>1 && (nhw_kernel[scan-1]==20000 || nhw_kernel[scan-1]==(sharpn2+21)))
{
if (!t4)
{
Expand All @@ -683,6 +672,27 @@ void pre_processing(image_buffer *im)
}
else t4 = 0;
}
else if (j>1 && nhw_kernel[scan-1]== -(sharpn2+21))
{
if (!t5)
{
t5 = 1;
}
else
{
if (!t4)
{
a = 0;
if (!t2) t2 = 1;

t4 = 1;
}
else t4 = 0;

if (t5==1) t5 = 2;
else t5 = 0;
}
}

if (!a)
{
Expand Down Expand Up @@ -720,6 +730,17 @@ void pre_processing(image_buffer *im)

a = 0;

if (im->setup->quality_setting<=LOW4)
{
for (i=(2*IM_DIM);i<((4*IM_SIZE)-(2*IM_DIM));i+=(2*IM_DIM))
{
for (scan=i+1,j=1;j<((2*IM_DIM)-1);j++,scan++)
{
if (nhw_kernel[scan]==20000) nhw_kernel[scan]= -(sharpn2+21);
}
}
}

if (im->setup->quality_setting<=LOW4) nhw_sharp_on=(char*)calloc(4*IM_SIZE,sizeof(char));

for (i=(2*IM_DIM);i<((4*IM_SIZE)-(2*IM_DIM));i+=(2*IM_DIM))
Expand Down
8 changes: 4 additions & 4 deletions encoder/nhw_encoder_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
****************************************************************************
* NHW Image Codec *
* file: nhw_encoder_cli.c *
* version: 0.3.0-rc6 *
* last update: $ 12282023 nhw exp $ *
* version: 0.3.0-rc7 *
* last update: $ 01052024 nhw exp $ *
* *
****************************************************************************
****************************************************************************
Expand All @@ -12,7 +12,7 @@
* remark: -simple codec *
***************************************************************************/

/* Copyright (C) 2007-2023 NHW Project
/* Copyright (C) 2007-2024 NHW Project
Written by Raphael Canut - nhwcodec_at_gmail.com */
/*
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -50,7 +50,7 @@
#include "codec.h"

#define PROGRAM "nhw-enc"
#define VERSION "0.3.0-rc6"
#define VERSION "0.3.0-rc7"

#define NHW_QUALITY_MIN LOW20
#define NHW_QUALITY_MAX HIGH3
Expand Down

0 comments on commit 1cc8974

Please sign in to comment.