Skip to content

Commit

Permalink
add overexposure image generator
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasxlu committed Apr 12, 2020
1 parent a071654 commit db51db1
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
.idea/
XCloud/__pycache__/
cv/__pycache__/
cv/static/FaceUpload/
dm/__pycache__/
nlp/__pycache__/
__pycache__/
pyWeb/
research/imgcensor/model/
cv/model/
cv/static/ImgCensorUpload/
cv/static/SkinUpload/
cv/static
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ with open("/path/to/test.jpg", mode='rb') as f:

## Note
* XCloud is freely accessible for everyone, you can email me AT
**[email protected]** to inquiry tech support.
**[email protected]** to inquire tech support.
* **Please ensure that your machine has a strong GPU equipment**.
* For [XCloud in Java](https://github.com/lucasxlu/CVLH.git), please refer to [CVLH](https://github.com/lucasxlu/CVLH.git) for more details!
* Technical details can be read from our [Technical Report](https://arxiv.org/abs/1912.10344).
Expand Down
7 changes: 7 additions & 0 deletions research/iqa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ the deep models to satisfy our requirement. You can also set the last output neu

- I replace the input channel as RGB instead of Gray-scale, since I find RGB input improves accuracy, I also add BatchNorm as a standard component as in SOTA CNN architecture.

- I also provide related code for [blur image generation](blur_creator.py),
[warp transformation](./lean_pose_creator.py) and [overexposure image
generation](./overexposure_creator.py).

## Performance Evaluation
I adopt these models mentioned above for ``exposure/edge recognition`` in ``product recognition project`` to reject unqualified images. The performance is listed as follows, you can train your own model with the code provided within this module.

Expand Down Expand Up @@ -52,3 +56,6 @@ I adopt these models mentioned above for ``exposure/edge recognition`` in ``prod
3. Talebi, Hossein, and Peyman Milanfar. ["Nima: Neural image assessment."](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8352823) IEEE Transactions on Image Processing 27.8 (2018): 3998-4011.
4. Bosse S, Maniry D, Wiegand T, et al. [A deep neural network for image quality assessment](http://iphome.hhi.de/samek/pdf/BosICIP16.pdf)[C]//2016 IEEE International Conference on Image Processing (ICIP). IEEE, 2016: 3773-3777.
5. Bianco S, Celona L, Napoletano P, et al. [On the use of deep learning for blind image quality assessment](https://arxiv.org/pdf/1602.05531.pdf)[J]. Signal, Image and Video Processing, 2018, 12(2): 355-362.
6. Bansal, Raghav, Gaurav Raj, and Tanupriya Choudhury. ["Blur image
detection using Laplacian operator and Open-CV."](https://ieeexplore.ieee.org/abstract/document/7894491/) 2016 International
Conference System Modeling & Advancement in Research Trends (SMART). IEEE, 2016.
56 changes: 56 additions & 0 deletions research/iqa/overexposure_creator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# generate over samples from clear images
# author: @LucasX
import argparse
import os
import random
import numpy as np

import cv2

parser = argparse.ArgumentParser()
parser.add_argument('-orig_dir', type=str,
default='C:/Users/LucasX/Desktop/ShelfExposure/normal')
parser.add_argument('-outpur_dir', type=str,
default='C:/Users/LucasX/Desktop/ShelfExposure/exposure')
parser.add_argument('-alpha', type=float, default=2.0)
parser.add_argument('-beta', type=float, default=0.0)
parser.add_argument('-show', type=bool, default=False)
args = vars(parser.parse_args())

print('-' * 100)
for key, value in args.items():
print('%s = %s' % (key, value))
print('-' * 100)


def modify_img_saturation(img_f):
"""
modify image saturation to imitate overexposure effect
:param img_f:
:return:
"""
if img_f.endswith('.jpg') or img_f.endswith('.png') or img_f.endswith('.jpeg'):
if not os.path.exists(args['outpur_dir']):
os.makedirs(args['outpur_dir'])
image = cv2.imread(img_f)

overexposure_image = np.zeros(image.shape, image.dtype)

for y in range(image.shape[0]):
for x in range(image.shape[1]):
for c in range(image.shape[2]):
# alpha = args['alpha']
alpha = random.randint(2, 10)
overexposure_image[y, x, c] = np.clip(alpha * image[y, x, c] + args['beta'], 0, 255)

if args['show'] and overexposure_image is not None:
cv2.imshow('overexposure_image', overexposure_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

cv2.imwrite(os.path.join(args['outpur_dir'], os.path.basename(img_f)), overexposure_image)


if __name__ == '__main__':
for img_f in os.listdir(args['orig_dir']):
modify_img_saturation(os.path.join(args['orig_dir'], img_f))

0 comments on commit db51db1

Please sign in to comment.