Skip to content

Commit

Permalink
Merge pull request cruxopen#22 from Kuo-TingKai/kevin-branch
Browse files Browse the repository at this point in the history
add docstring in execute
  • Loading branch information
cruxopen authored Feb 1, 2023
2 parents 0cc7682 + 7c1ac49 commit d4947e1
Show file tree
Hide file tree
Showing 6 changed files with 511 additions and 12 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/git-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Kevin's GitHub Actions
on:
push:
branches:
- "master"
- "kevin-branch"
pull_request:
branches: ["master"]

jobs:
Kevin-build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [12.x]
steps:
- run: echo "? The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "? This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "? The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v2
with:
fetch-depth: 0
- run: echo "? The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "?️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "? This job's status is ${{ job.status }}."
111 changes: 111 additions & 0 deletions config/config_test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Variables,Values,Description
raw_w,192,Raw image width
raw_h,108,Raw image height
dpc_thres,30,DPC threshold
dpc_mode,gradient,DPC mode
dpc_clip,1023,DPC clip value
bayer_pattern,rggb,Bayer pattern
bl_r,0,Black level offset of Red channel
bl_gr,0,Black level offset of Green(R) channel
bl_gb,0,Black level offset of Green(B) channel
bl_b,0,Black level offset of Blue channel
alpha,0,Fusion parameter for Red channel
beta,0,Fusion parameter for Blue channel
blc_clip,1023,BLC clip value
r_gain,1.5,AWB Red gain
gr_gain,1,AWB Green(R) gain
gb_gain,1.1,AWB Green(B) gain
awb_clip,1023,AWB clip value
cfa_mode,malvar,Demosaic mode
cfa_clip,1023,CFA clip value
ccm_00,1024,CCM
ccm_01,0,CCM
ccm_02,0,CCM
ccm_03,0,CCM offset
ccm_10,0,CCM
ccm_11,1024,CCM
ccm_12,0,CCM
ccm_13,0,CCM offset
ccm_20,0,CCM
ccm_21,0,CCM
ccm_22,1024,CCM
ccm_23,0,CCM offset
csc_00,0.257,CSC
csc_01,0.504,CSC
csc_02,0.098,CSC
csc_03,16,CSC offset
csc_10,-0.148,CSC
csc_11,-0.291,CSC
csc_12,0.439,CSC
csc_13,128,CSC offset
csc_20,0.439,CSC
csc_21,-0.368,CSC
csc_22,-0.071,CSC
csc_23,128,CSC offset
bnf_dw_00,8,BNF distance weights
bnf_dw_01,12,BNF distance weights
bnf_dw_02,32,BNF distance weights
bnf_dw_03,12,BNF distance weights
bnf_dw_04,8,BNF distance weights
bnf_dw_10,12,BNF distance weights
bnf_dw_11,64,BNF distance weights
bnf_dw_12,128,BNF distance weights
bnf_dw_13,64,BNF distance weights
bnf_dw_14,12,BNF distance weights
bnf_dw_20,32,BNF distance weights
bnf_dw_21,128,BNF distance weights
bnf_dw_22,1024,BNF distance weights
bnf_dw_23,128,BNF distance weights
bnf_dw_24,32,BNF distance weights
bnf_dw_30,12,BNF distance weights
bnf_dw_31,64,BNF distance weights
bnf_dw_32,128,BNF distance weights
bnf_dw_33,64,BNF distance weights
bnf_dw_34,12,BNF distance weights
bnf_dw_40,8,BNF distance weights
bnf_dw_41,12,BNF distance weights
bnf_dw_42,32,BNF distance weights
bnf_dw_43,12,BNF distance weights
bnf_dw_44,8,BNF distance weights
bnf_rw_0,0,BNF radiometric diff
bnf_rw_1,8,BNF radiometric diff
bnf_rw_2,16,BNF radiometric diff
bnf_rw_3,32,BNF radiometric diff
bnf_rthres_0,128,BNF diff threshold
bnf_rthres_1,32,BNF diff threshold
bnf_rthres_2,8,BNF diff threshold
bnf_clip,255,BNF clip value
edge_filter_00,-1,Edge filter
edge_filter_01,0,Edge filter
edge_filter_02,-1,Edge filter
edge_filter_03,0,Edge filter
edge_filter_04,-1,Edge filter
edge_filter_10,-1,Edge filter
edge_filter_11,0,Edge filter
edge_filter_12,8,Edge filter
edge_filter_13,0,Edge filter
edge_filter_14,-1,Edge filter
edge_filter_20,-1,Edge filter
edge_filter_21,0,Edge filter
edge_filter_22,-1,Edge filter
edge_filter_23,0,Edge filter
edge_filter_24,-1,Edge filter
ee_gain_min,32,Edge enhancement min gain
ee_gain_max,128,Edge enhancement max gain
ee_thres_min,32,Edge enhancement min threshold
ee_thres_max,64,Edge enhancement max threshold
ee_emclip_min,-64,Edge map min clip value
ee_emclip_max,64,Edge map max clip value
fcs_edge_min,32,FCS edge min value
fcs_edge_max,64,FCS edge max value
fcs_gain,32,FCS gain
fcs_intercept,2,FCS intercept
fcs_slope,3,FCS slope
nlm_h,15,NLM sigma
nlm_clip,255,NLM clip
hue,128,Hue value
saturation,256,Saturation gain
hsc_clip,255,HSC clip value
brightness,10,Brightness
contrast,10,Contast gain
bcc_clip,255,BCC clip value
4 changes: 3 additions & 1 deletion model/bnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ def execute(self):
rdiff = np.zeros((5,5), dtype='uint16')
for y in range(img_pad.shape[0] - 4):
for x in range(img_pad.shape[1] - 4):
print("[x,y]:["+str(x)+','+str(y)+']')
for i in range(5):
for j in range(5):
rdiff[i,j] = abs(img_pad[y+i,x+j] - img_pad[y+2, x+2])
rdiff[i,j] = abs(img_pad[y+i,x+j].astype(int) - img_pad[y+2, x+2].astype(int))
# rdiff[i,j] = abs(img_pad[y+i,x+j] - img_pad[y+2, x+2])
if rdiff[i,j] >= self.rthres[0]:
rdiff[i,j] = self.rw[0]
elif rdiff[i,j] < self.rthres[0] and rdiff[i,j] >= self.rthres[1]:
Expand Down
41 changes: 30 additions & 11 deletions model/dpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,40 @@ def clipping(self):
return self.img

def execute(self):

"""
Pixel array in code is showed above:
p1 p2 p3
p4 p0 p5
p6 p7 p8
it makes sense for calculating follow-up gradients of pixel values (horizontal,vertical,left/right diagonal).
"""


img_pad = self.padding()
raw_h = self.img.shape[0]
raw_w = self.img.shape[1]
dpc_img = np.empty((raw_h, raw_w), np.uint16)
dpc_img = np.empty((raw_h, raw_w), np.uint16)
# change uint16 to int_, still exists overflow warning in the following abs calculation
for y in range(img_pad.shape[0] - 4):
for x in range(img_pad.shape[1] - 4):
p0 = img_pad[y + 2, x + 2]
p1 = img_pad[y, x]
p2 = img_pad[y, x + 2]
p3 = img_pad[y, x + 4]
p4 = img_pad[y + 2, x]
p5 = img_pad[y + 2, x + 4]
p6 = img_pad[y + 4, x]
p7 = img_pad[y + 4, x + 2]
p8 = img_pad[y + 4, x + 4]



p0 = img_pad[y + 2, x + 2].astype(int)
p1 = img_pad[y, x].astype(int)
p2 = img_pad[y, x + 2].astype(int)
p3 = img_pad[y, x + 4].astype(int)
p4 = img_pad[y + 2, x].astype(int)
p5 = img_pad[y + 2, x + 4].astype(int)
p6 = img_pad[y + 4, x].astype(int)
p7 = img_pad[y + 4, x + 2].astype(int)
p8 = img_pad[y + 4, x + 4].astype(int)



if (abs(p1 - p0) > self.thres) and (abs(p2 - p0) > self.thres) and (abs(p3 - p0) > self.thres) \
and (abs(p4 - p0) > self.thres) and (abs(p5 - p0) > self.thres) and (abs(p6 - p0) > self.thres) \
and (abs(p7 - p0) > self.thres) and (abs(p8 - p0) > self.thres):
Expand All @@ -52,7 +71,7 @@ def execute(self):
p0 = (p1 + p8 + 1) / 2
else:
p0 = (p3 + p6 + 1) / 2
dpc_img[y, x] = p0
dpc_img[y, x] = p0.astype('uint16')
self.img = dpc_img
return self.clipping()

Binary file added raw/test_12_bit_img.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d4947e1

Please sign in to comment.