2022-09-23
Image Blur Detection, Image Quality Assessment

blur detection, detect blur/nonblur area, score the image

traditional methods

score and output mask for blurry areas using laplacian

using fourier transform

This project outputs regions in an image which are sharp and blurry. In order to perform “OUT-OF-FOCUS” blur estimation, please refer to this repo

deeplearning blur image classification/scoring

Image-Quality-Detection

Blur-Image-Detection

Read More

2022-09-18
Image Resize, Image Padding, Image Scanning

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def scanImageWithWindowSizeAutoResize(
image,
width,
height,
return_direction=False,
threshold=0.1, # minimum 'fresh' area left for scanning
): # shall you use torch? no?
shape = image.shape
assert len(shape) == 3
ih, iw, channels = shape
targetWidth = max(width, math.floor(iw * height / ih))
targetHeight = max(height, math.floor(ih * width / iw))
resized = cv2.resize(
image, (targetWidth, targetHeight), interpolation=cv2.INTER_CUBIC
)
# determine scan direction here.
imageSeries = []
if targetWidth / targetHeight == width / height:
imageSeries = [resized] # as image series.
direction = None
elif targetWidth / targetHeight < width / height:
direction = "vertical"
# the scanning is along the vertical axis, which is the height.
index = 0
while True:
start, end = height * index, height * (index + 1)
if start < targetHeight:
if end > targetHeight:
if 1 - (end - targetHeight) / targetHeight >= threshold:
end = targetHeight
start = targetHeight - height
else:
break
# other conditions, just fine
else:
break # must exit since nothing to scan.
cropped = resized[start:end, :, :] # height, width, channels
imageSeries.append(cropped)
index += 1
else:
direction = "horizontal"
index = 0
while True:
start, end = width * index, width * (index + 1)
if start < targetWidth:
if end > targetWidth:
if 1 - (end - targetWidth) / targetWidth >= threshold:
end = targetWidth
start = targetWidth - width
else:
break
# other conditions, just fine
else:
break # must exit since nothing to scan.
cropped = resized[:, start:end, :] # height, width, channels
imageSeries.append(cropped)
index += 1
if return_direction:
return imageSeries, direction
else:
return imageSeries
def resizeImageWithPadding(
image,
width,
height,
border_type: Literal["constant_black", "replicate"] = "constant_black",
):
shape = image.shape
assert len(shape) == 3
ih, iw, channels = shape
targetWidth = min(width, math.floor(iw * height / ih))
targetHeight = min(height, math.floor(ih * width / iw))
resized = cv2.resize(
image, (targetWidth, targetHeight), interpolation=cv2.INTER_CUBIC
)
BLACK = [0] * channels
top = max(0, math.floor((height - targetHeight) / 2))
bottom = max(0, height - targetHeight - top)
left = max(0, math.floor((width - targetWidth) / 2))
right = max(0, width - targetWidth - left)
if border_type == "constant_black":
padded = cv2.copyMakeBorder(
resized, top, bottom, left, right, cv2.BORDER_CONSTANT, value=BLACK
)
elif border_type == "replicate":
padded = cv2.copyMakeBorder(
resized, top, bottom, left, right, cv2.BORDER_REPLICATE, value=BLACK
)
else:
raise Exception("unknown border_type: %s" % border_type)
return padded

Read More

2022-09-17
Color Transfer Between Images, Histogram Based Style Transfer

图像调色风格转换 可以创建蹦迪特效 让视频或者图片五彩斑斓

color transfer between images

1
2
pip install color_transfer

official scikit-learn histogram matching

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import matplotlib.pyplot as plt
from skimage import data
from skimage import exposure
from skimage.exposure import match_histograms
reference = data.coffee()
image = data.chelsea()
matched = match_histograms(image, reference, channel_axis=-1)
fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(8, 3),
sharex=True, sharey=True)
for aa in (ax1, ax2, ax3):
aa.set_axis_off()
ax1.imshow(image)
ax1.set_title('Source')
ax2.imshow(reference)
ax2.set_title('Reference')
ax3.imshow(matched)
ax3.set_title('Matched')
plt.tight_layout()
plt.show()

histogram matching

Read More

2022-05-28
Ai上色

Read More

2022-05-09
Video Anticensor

Video Anticensor For Bilibili Tarot

paddlegan coloring images

could use p5 to do part of the job.

video:

style transfer

glitch

picture to sketch -> ai painting

grayscale -> ai coloring

dithering

chroma shift(hue)

(gradient/video) overlay

dashing/filtering, could be done in 2 frames or more

random pixel noise

text:

inverted canny edge

handwritten font

italic

pixelize, blur

boxing texts

slashing texts

rotating texts (30 degree?)

coloring texts

different font size

(randomly) censor words into letters

reshape (decrese height or width)

audio:

vocoder

style change

pitch change

Read More