Skip to content

Commit

Permalink
test finish, add python mat
Browse files Browse the repository at this point in the history
  • Loading branch information
IceClear committed Nov 30, 2021
1 parent 6dc849c commit 0018f12
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion IL-NIQE.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def ilniqe(img, mu_pris_param, cov_pris_param, gaussian_window, principleVectors
nanConst = 2000

if resize:
img = cv2.resize(img, (normalizedWidth, normalizedWidth),interpolation=cv2.INTER_AREA)
img = cv2.resize(img, (normalizedWidth, normalizedWidth), interpolation=cv2.INTER_AREA)
h, w, _ = img.shape

num_block_h = math.floor(h / block_size_h)
Expand Down Expand Up @@ -437,6 +437,9 @@ def calculate_ilniqe(img, crop_border, input_order='HWC', num_cpus=3, resize=Tru

ilniqe_result = ilniqe(img, mu_pris_param, cov_pris_param, gaussian_window, principleVectors, meanOfSampleData, resize)

if isinstance(ilniqe_result, complex) and ilniqe_result.imag == 0:
ilniqe_result = ilniqe_result.real

return ilniqe_result

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can also train your own model via training.m in the Matlab version. But the

## Results

|Image|IL-NIQE (using official .mat, Matlab/Python)|IL-NIQE (using .mat trained in python, Matlab/Python)|IL-NIQE (w/o imresize) (Matlab/Python)|Time(sec) (Matlab/Python)|
|Image|IL-NIQE (using official .mat) (Matlab/Python)|IL-NIQE (using .mat trained in python) (Python)|IL-NIQE (w/o imresize) (Matlab/Python)|Time(sec) (Matlab/Python)|
|:-|:-|:-|:-|:-|
|pepper_0.png|29.1422 / 27.3655|28.1166|38.7078 / 38.9319|9.9567 / 103.4350|
|pepper_1.png|36.9637 / 39.0683|38.7309|36.6869 / 37.0163|9.7487 / 90.1218|
Expand Down
Binary file added python_templateModel.mat
Binary file not shown.
8 changes: 4 additions & 4 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ def train(data_path):
cov_prisparam = np.cov(prisparam_no_nan, rowvar=False)

templateModel = []
templateModel.append(np.real(mu_prisparam) if isinstance(mu_prisparam,complex) else mu_prisparam)
templateModel.append(np.real(cov_prisparam) if isinstance(cov_prisparam,complex) else cov_prisparam)
templateModel.append(np.real(meanOfSampleData) if isinstance(meanOfSampleData,complex) else meanOfSampleData)
templateModel.append(np.real(principleVectors) if isinstance(principleVectors,complex) else principleVectors)
templateModel.append(mu_prisparam)
templateModel.append(cov_prisparam)
templateModel.append(meanOfSampleData)
templateModel.append(principleVectors)

scipy.io.savemat('./python_templateModel.mat', {'templateModel':[templateModel]})

Expand Down

0 comments on commit 0018f12

Please sign in to comment.