Skip to content

Commit

Permalink
version 0.3.0-rc8
Browse files Browse the repository at this point in the history
fine-tune the nhw_kernel weights and pre_processing
  • Loading branch information
rcanut committed Jan 11, 2024
1 parent 1cc8974 commit 3494891
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 23 deletions.
64 changes: 44 additions & 20 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-rc7 *
* last update: $ 01052024 nhw exp $ *
* version: 0.3.0-rc8 *
* last update: $ 01112024 nhw exp $ *
* *
****************************************************************************
****************************************************************************
Expand Down Expand Up @@ -626,7 +626,7 @@ void pre_processing(image_buffer *im)

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

res3 = 1;
}
Expand Down Expand Up @@ -661,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 && (nhw_kernel[scan-1]==20000 || nhw_kernel[scan-1]==(sharpn2+21)))
else if (j>1 && (abs(nhw_kernel[scan-1])>10000 || nhw_kernel[scan-1]==(sharpn2+21)))
{
if (!t4)
{
Expand Down Expand Up @@ -696,7 +696,7 @@ void pre_processing(image_buffer *im)

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

a = 1;
}
Expand Down Expand Up @@ -730,17 +730,6 @@ 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 Expand Up @@ -813,12 +802,20 @@ void pre_processing(image_buffer *im)
}
else
{
if (abs(res)>sharpness)
if (abs(res)>10000)
{
if (res==20000) im->im_jpeg[scan-1]++;else im->im_jpeg[scan-1]--;
}
else if (abs(res)>sharpness)
{
if (res>0) im->im_jpeg[scan-1]++;else im->im_jpeg[scan-1]--;
}

if (abs(count)>sharpness)

if (abs(count)>10000)
{
if (count==20000) im->im_jpeg[scan]++;else im->im_jpeg[scan]--;
}
else if (abs(count)>sharpness)
{
if (count>0) im->im_jpeg[scan]++;else im->im_jpeg[scan]--;
}
Expand Down Expand Up @@ -907,7 +904,7 @@ void pre_processing(image_buffer *im)

if (im->setup->quality_setting<=LOW4)
{
for (i=(2*IM_DIM);i<((4*IM_SIZE)-(2*IM_DIM));i+=(2*IM_DIM))
for (i=(2*IM_DIM),t1=0,t2=0;i<((4*IM_SIZE)-(2*IM_DIM));i+=(2*IM_DIM))
{
for (scan=i+1,j=1,e=0,t=0,f=0;j<((2*IM_DIM)-3);j++,scan++)
{
Expand All @@ -917,6 +914,33 @@ void pre_processing(image_buffer *im)

count= nhw_kernel[scan];

if (abs(res)>10000)
{
if (res==20000) nhw_kernel[scan-1]=sharpn2+21;else nhw_kernel[scan-1]= -(sharpn2+21);

if(!t2)
{
if (count==20000) nhw_kernel[scan]=sharpn2+21;else if (count== -20000) nhw_kernel[scan]= -(sharpn2+21);

t2 = 1;
}
else t2 = 0;

if (!t1)
{
t1 = 1;

continue;
}
else t1 = 0;
}
else if (abs(count)>10000)
{
if (count==20000) nhw_kernel[scan]=sharpn2+21;else nhw_kernel[scan]= -(sharpn2+21);

continue;
}

if (abs(res)>(sharpness+20) && abs(count)>(sharpness>>1) && abs(count)<=sharpn2)
{
if (res>0)
Expand Down
6 changes: 3 additions & 3 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-rc7 *
* last update: $ 01052024 nhw exp $ *
* version: 0.3.0-rc8 *
* last update: $ 01112024 nhw exp $ *
* *
****************************************************************************
****************************************************************************
Expand Down Expand Up @@ -50,7 +50,7 @@
#include "codec.h"

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

#define NHW_QUALITY_MIN LOW20
#define NHW_QUALITY_MAX HIGH3
Expand Down

0 comments on commit 3494891

Please sign in to comment.