-
Notifications
You must be signed in to change notification settings - Fork 0
/
convolve_rough.jl
445 lines (393 loc) · 20.9 KB
/
convolve_rough.jl
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# import OpenCV.getGaussianKernel
using OpenCV
using CUDA
# using Images
function gaussian_kernel_unopt(inp, conv, out, width, height, apron)
x, y = threadIdx().x, threadIdx().y
X, Y = blockIdx().x, blockIdx().y
if x <= width - 2 * apron && y <= height - 2 * apron
out[x, y] = sum(inp[x:x+2*apron, y:y+2*apron] .* conv)
end
return
end
function row_kernel(inp, conv, out, width, height, apron, print)
blockNum::UInt16 = (blockIdx().x - 1) + (blockIdx().y - 1) * gridDim().x # column major block numbering, zero-based
threadNum::UInt16 = (threadIdx().x - 1) + (threadIdx().y - 1) * blockDim().x # column major thread numbering in a block, zero-based
# not sure why unsigned uint16 doesn't work
threads::Int16 = blockDim().x * blockDim().y # total number of threads in a block
# if threadNum == 5 && blockNum == 0 && print == 1
# @cuprintln("threads: ", threads)
# # @cuprintln("threadNum: ", threadNum)
# # @cuprintln("blockNum: ", blockNum)
# # @cuprintln("sharedMemDim: ", (width, threads ÷ width))
# # @cuprintln("TypeOf threads: ", typeof(threads))
# end
# "this" refers to the current pixel in the input image
# "that" refers to the current pixel in the output image
thisX::Int16 = 0 # one-based
thisY::Int16 = 0 # one-based
thisPX::Int32 = 0 # zero-based
# Let's do the row first
# if thread count is greater than one row
if threads >= width
# we'll do (width) * (threads ÷ width) pixels in a block
data = CuDynamicSharedArray(Float32, (width, threads ÷ width))
# outDatas = CuDynamicSharedArray(Float32, threads)
# data = @cuStaticSharedMem(Float32, 5)
if threadNum < width * (threads ÷ width)
thisPX = blockNum * width * (threads ÷ width) + threadNum # zero-based
if true
thisX = thisPX % width + 1 # one-based
thisY = (thisPX - thisX + 1) ÷ width + 1 # one-based
# if threadNum == 5 && blockNum == 0 && print == 1
# @cuprintln("thisX: ", thisX)
# @cuprintln("thisY: ", thisY)
# @cuprintln("dataXY: ", (threadNum % width + 1, (threadNum - threadNum % width) ÷ width + 1))
# # @cuprintln("img: ", inp[thisPX])
# end
# coalesced memory access
if (0 <= thisPX < width * height)
X::Int16 = threadNum % width + 1
Y::Int16 = (threadNum - (X - 1)) ÷ width + 1
data[X, Y] = inp[thisPX+1]
end
sync_threads()
end
# thatX = thisX - apron # one-based
# thatY = thisY # one-based
if apron < threadNum % width + 1 <= width - apron && 0 <= thisPX < width * height
# X = threadNum % width + 1
# Y = (threadNum - (X - 1)) ÷ width + 1
outData::Float32 = 0
# outDatas[threadNum+1] = 0.0
for i in -apron:apron
# # don't use threadNum here
outData += data[threadNum%width+1+i, (threadNum-(X-1))÷width+1] * conv[i+apron+1]
# outDatas[threadNum+1] += data[threadNum%width+1+i, (threadNum-(X-1))÷width+1] * conv[i+apron+1]
# # solution to too many resources here would be to allocate a shared memory array that stores thisX and thisY or some variable.
end
out[1, threadNum%width+1-apron, blockNum*(threads÷width)+(threadNum-(X-1))÷width+1] = outData
# out[1, threadNum%width+1-apron, blockNum*(threads÷width)+(threadNum-(X-1))÷width+1] = outDatas[threadNum+1]
end
end
else
# we'll do threads pixels in a block
data = CuDynamicSharedArray(Float32, threads)
# outDatas = CuDynamicSharedArray(Float32, threads)
# total blocks in a row = width ÷ threads + 1
# "this" refers to the current pixel in the input image
thisY = blockNum ÷ (cld(width - 2 * apron, threads - 2 * apron)) + 1 # one-based
thisX = (blockNum % (cld(width - 2 * apron, threads - 2 * apron))) * (threads - 2 * apron) + threadNum + 1 # one-based
if 0 < thisX <= width && 0 < thisY <= height
thisPX = (thisY - 1) * width + (thisX - 1) # zero-based
data[threadNum+1] = inp[thisPX+1]
end
sync_threads()
if thisX <= width - apron && 0 < thisY <= height && apron <= threadNum < threads - apron
outData = 0.0
# outDatas[threadNum+1] = 0.0
for i in -apron:apron
outData += data[threadNum+1+i] * conv[i+apron+1]
# outDatas[threadNum+1] += data[threadNum+1+i] * conv[i+apron+1]
end
out[1, thisX-apron, thisY] = outData
# out[1, thisX-apron, thisY] = outDatas[threadNum+1]
end
end
# if threadNum == 5 && blockNum == 0
# @cuprintln("row kernel done")
# end
return
end
function row_kernel_strips(inp, conv, out, width, height, apron, print)
blockNum::UInt16 = (blockIdx().x - 1) + (blockIdx().y - 1) * gridDim().x # column major block numbering, zero-based
threadNum::UInt16 = (threadIdx().x - 1) + (threadIdx().y - 1) * blockDim().x # column major thread numbering in a block, zero-based
# not sure why unsigned uint16 doesn't work
threads::Int16 = blockDim().x * blockDim().y # total number of threads in a block
# if threadNum == 5 && blockNum == 0 && print == 1
# @cuprintln("threads: ", threads)
# # @cuprintln("threadNum: ", threadNum)
# # @cuprintln("blockNum: ", blockNum)
# # @cuprintln("sharedMemDim: ", (width, threads ÷ width))
# # @cuprintln("TypeOf threads: ", typeof(threads))
# end
# "this" refers to the current pixel in the input image
# "that" refers to the current pixel in the output image
thisX::Int16 = 0 # one-based
thisY::Int16 = 0 # one-based
thisPX::Int32 = 0 # zero-based
# Let's do the row first
# if thread count is greater than one row
# we'll do (width) * (threads ÷ width) pixels in a block
data = CuDynamicSharedArray(Float32, (width, threads ÷ width))
# outDatas = CuDynamicSharedArray(Float32, threads)
# data = @cuStaticSharedMem(Float32, 5)
if threadNum < width * (threads ÷ width)
thisPX = blockNum * width * (threads ÷ width) + threadNum # zero-based
if true
thisX = thisPX % width + 1 # one-based
thisY = (thisPX - thisX + 1) ÷ width + 1 # one-based
# if threadNum == 5 && blockNum == 0 && print == 1
# @cuprintln("thisX: ", thisX)
# @cuprintln("thisY: ", thisY)
# @cuprintln("dataXY: ", (threadNum % width + 1, (threadNum - threadNum % width) ÷ width + 1))
# # @cuprintln("img: ", inp[thisPX])
# end
# coalesced memory access
if (0 <= thisPX < width * height)
X::Int16 = threadNum % width + 1
Y::Int16 = (threadNum - (X - 1)) ÷ width + 1
data[X, Y] = inp[thisPX+1]
end
sync_threads()
end
# thatX = thisX - apron # one-based
# thatY = thisY # one-based
if apron < threadNum % width + 1 <= width - apron && 0 <= thisPX < width * height
# X = threadNum % width + 1
# Y = (threadNum - (X - 1)) ÷ width + 1
outData::Float32 = 0
# outDatas[threadNum+1] = 0.0
for i in -apron:apron
# # don't use threadNum here
outData += data[threadNum%width+1+i, (threadNum-(X-1))÷width+1] * conv[i+apron+1]
# outDatas[threadNum+1] += data[threadNum%width+1+i, (threadNum-(X-1))÷width+1] * conv[i+apron+1]
# # solution to too many resources here would be to allocate a shared memory array that stores thisX and thisY or some variable.
end
out[1, threadNum%width+1-apron, blockNum*(threads÷width)+(threadNum-(X-1))÷width+1] = outData
# out[1, threadNum%width+1-apron, blockNum*(threads÷width)+(threadNum-(X-1))÷width+1] = outDatas[threadNum+1]
end
end
# if threadNum == 5 && blockNum == 0
# @cuprintln("row kernel done")
# end
return
end
function row_kernel_strip(inp, conv, out, width, height, apron, print)
blockNum::UInt16 = (blockIdx().x - 1) + (blockIdx().y - 1) * gridDim().x # column major block numbering, zero-based
threadNum::UInt16 = (threadIdx().x - 1) + (threadIdx().y - 1) * blockDim().x # column major thread numbering in a block, zero-based
# not sure why unsigned uint16 doesn't work
threads::Int16 = blockDim().x * blockDim().y # total number of threads in a block
# "this" refers to the current pixel in the input image
# "that" refers to the current pixel in the output image
thisX::Int16 = 0 # one-based
thisY::Int16 = 0 # one-based
thisPX::Int32 = 0 # zero-based
# Let's do the row first
# we'll do threads pixels in a block
data = CuDynamicSharedArray(Float32, threads)
# total blocks in a row = width ÷ threads + 1
# "this" refers to the current pixel in the input image
thisY = blockNum ÷ (cld(width - 2 * apron, threads - 2 * apron)) + 1 # one-based
thisX = (blockNum % (cld(width - 2 * apron, threads - 2 * apron))) * (threads - 2 * apron) + threadNum + 1 # one-based
if 0 < thisX <= width && 0 < thisY <= height
thisPX = (thisY - 1) * width + (thisX - 1) # zero-based
data[threadNum+1] = inp[thisPX+1]
end
sync_threads()
if thisX <= width - apron && 0 < thisY <= height && apron <= threadNum < threads - apron
outData = 0.0
for i in -apron:apron
outData += data[threadNum+1+i] * conv[i+apron+1]
end
out[1, thisX-apron, thisY] = outData
end
return
end
function col_kernel(inp, conv, out, width, fullHeight, height, apron)
blockNum = (blockIdx().x - 1) * gridDim().y + (blockIdx().y - 1) # row first block numbering, zero-based
threadNum = (threadIdx().x - 1) + (threadIdx().y - 1) * blockDim().x # row first thread numbering in a block, zero-based
threads = blockDim().x * blockDim().y # total number of threads in a block
threadsX = blockDim().x
# "this" refers to the current pixel in the input image
# "that" refers to the current pixel in the output image
if threads <= fullHeight
data = CuDynamicSharedArray(Float32, (threadsX, threads ÷ threadsX))
blocksInARow::Int16 = cld(width - 2 * apron, threadsX) # this is the number of blocks in a row of the image (width)
blocksInAColumn::Int16 = cld(height - 2 * apron, threads ÷ threadsX - 2 * apron) # this is the number of blocks in a column of the image (height)
blocksInAnImage::Int32 = blocksInARow * blocksInAColumn
thisImage::Int8 = blockNum ÷ blocksInAnImage # zero-based
thisBlockNum::Int16 = blockNum % blocksInAnImage # zero-based
thisX::Int16 = (thisBlockNum ÷ blocksInAColumn) * threadsX + threadNum % threadsX + 1 # one-based
thisY::Int32 = thisImage * height + (thisBlockNum % blocksInAColumn) * (threads / threadsX - 2 * apron) + threadNum ÷ threadsX + 1 # one-based
thisPX::Int32 = (thisY - 1) * (width - 2 * apron) + (thisX - 1) # zero-based
if 0 <= thisPX < (width - 2 * apron) * fullHeight
data[threadNum+1] = inp[thisPX+1]
end
sync_threads()
if 0 < thisX <= (width - 2 * apron) && apron < thisY <= fullHeight - apron && apron <= (threadNum ÷ threadsX) < threads / threadsX - apron
outData = 0.0
for i in -apron:apron
outData += data[threadNum+i*threadsX+1] * conv[i+apron+1]
end
out[1, thisX, thisY-(thisImage)*2*apron-apron] = outData
end
end
return
end
function convolve(img, schema, imgHeight, print=1)
# function convolve(schema)
if schema[:name] == "gaussian1D"
sigma = convert(Float64, schema[:sigma])
epsilon = haskey(schema, :epsilon) ? schema[:epsilon] : 0.0001
apron = ceil(Int, sigma * sqrt(-2 * log(epsilon)))
conv = reshape(OpenCV.getGaussianKernel(2 * apron + 1, sigma), 2 * apron + 1)
if print == 1
println("Convolve with Gaussian1D")
println("Sigma: ", sigma)
println("Epsilon: ", epsilon)
println("Apron: ", apron)
# println("Grids: ", grids)
end
width::Int32, height::Int32 = (0, 0)
if length(size(img)) == 2
width, height = size(img)
else
channel, width, height = size(img)
end
if print == 1
println("Width: ", width, ", Height: ", height)
end
blocks_row = (32, 32)
blocks_col = (32, 28)
while blocks_col[2] - 2 * apron < 0 && blocks_col[1] > 4
blocks_col = (blocks_col[1] ÷ 2, blocks_col[2] * 2)
end
# grids = (cld(width, blocks[1]), cld(height, blocks[2]))
grids_row = cld((width - 2 * apron), blocks_row[1] * blocks_row[2] - 2 * apron) * height
# grids_col = cld((height - 2 * apron), blocks[2] - 2 * apron) * cld(width - 2 * apron, blocks[1]) * height ÷ imgHeight
grids_col = (cld(width - 2 * apron, blocks_col[1]), cld((height - 2 * apron), blocks_col[2] - 2 * apron) * height ÷ imgHeight)
# grids = 2
if print == 1
println("Blocks: ", blocks_row)
println("Blocks: ", blocks_col)
println("Grids, col: $grids_col, row: $grids_row")
end
# sharedMemSize_col = blocks[1] * blocks[2] * (sizeof(Float32))
inp_GPU = CuArray(img)
conv_GPU = CuArray(conv)
out_GPU = CuArray(zeros(Float32, 1, width - 2 * apron, height))
sharedMemSize = blocks_row[1] * blocks_row[2] * (sizeof(Float32)) #+ 1024 * sizeof(Float32)
if blocks_row[1] * blocks_row[2] >= width
# sharedMemSize_row = width * ((blocks[1] * blocks[2]) ÷ width) * (sizeof(Float32))
if print == 1
println("more than one row in a block")
# println("Shared memory size: ", sharedMemSize_row / 1024, " KB")
println("Shared memory size: ", sharedMemSize / 1024, " KB")
println("Convolution kernel: ", conv)
end
@cuda blocks = grids_row threads = blocks_row shmem = sharedMemSize row_kernel_strips(inp_GPU, conv_GPU, out_GPU, width, height, apron, print)
CUDA.unsafe_free!(inp_GPU)
@cuda blocks = grids_col threads = blocks_col shmem = sharedMemSize col_kernel(out_GPU, conv_GPU, inp_GPU, width, height, imgHeight, apron)
else
# sharedMemSize_row = blocks[1] * blocks[2] * (sizeof(Float32))
if print == 1
println("many blocks in a row")
# println("Shared memory size: ", sharedMemSize_row / 1024, " KB")
println("Shared memory size: ", sharedMemSize / 1024, " KB")
println("Convolution kernel: ", conv)
end
# @cuda blocks = grids_row threads = blocks_row shmem = sharedMemSize row_kernel(inp_GPU, conv_GPU, out_GPU, width, height, apron, print)
kernel = @cuda name = "row" launch = false row_kernel_strip(inp_GPU, conv_GPU, out_GPU, width, height, apron, print)
# config = launch_configuration(kernel.fun)
# println("Config: ", config)
kernel(inp_GPU, conv_GPU, out_GPU, width, height, apron, print, blocks=grids_row, threads=blocks_row, shmem=sharedMemSize)
CUDA.unsafe_free!(inp_GPU)
inp_GPU = CuArray(zeros(Float32, 1, width - 2 * apron, height - 2 * apron * height ÷ imgHeight))
@cuda blocks = grids_col threads = blocks_col shmem = sharedMemSize col_kernel(out_GPU, conv_GPU, inp_GPU, width, height, imgHeight, apron)
# kernel = @cuda name = "col" launch = false col_kernel(out_GPU, conv_GPU, inp_GPU, width, height, imgHeight, apron)
# config = launch_configuration(kernel.fun)
# println("Config: ", config)
# kernel(out_GPU, conv_GPU, inp_GPU, width, height, imgHeight, apron, blocks=grids_col, threads=blocks_col, shmem=sharedMemSize)
end
if print == 1
println("Done")
end
return Array(inp_GPU), Array(out_GPU)
return 1, 2
end
end
# img = rand(1500, 512)
# load from assets/lenna.png, use OpenCV
# img = OpenCV.imread("assets/lenna.png", OpenCV.IMREAD_GRAYSCALE)
img1 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_1.png", OpenCV.IMREAD_GRAYSCALE)
img2 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_2.png", OpenCV.IMREAD_GRAYSCALE)
img3 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_3.png", OpenCV.IMREAD_GRAYSCALE)
img4 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_4.png", OpenCV.IMREAD_GRAYSCALE)
# img5 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_5.png", OpenCV.IMREAD_GRAYSCALE)
# img6 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_6.png", OpenCV.IMREAD_GRAYSCALE)
# img7 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_7.png", OpenCV.IMREAD_GRAYSCALE)
# img8 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_8.png", OpenCV.IMREAD_GRAYSCALE)
# img9 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_9.png", OpenCV.IMREAD_GRAYSCALE)
# img10 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_10.png", OpenCV.IMREAD_GRAYSCALE)
# img11 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_11.png", OpenCV.IMREAD_GRAYSCALE)
# img12 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_12.png", OpenCV.IMREAD_GRAYSCALE)
# img13 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_13.png", OpenCV.IMREAD_GRAYSCALE)
# img14 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_14.png", OpenCV.IMREAD_GRAYSCALE)
# img15 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_15.png", OpenCV.IMREAD_GRAYSCALE)
# img16 = OpenCV.imread("assets/DJI_20240328_234918_14_null_beauty.mp4_frame_16.png", OpenCV.IMREAD_GRAYSCALE)
println(size(img1))
imgHeight = size(img1, 3)
start = time()
img1 = convert(Array{Float32}, img1)
img2 = convert(Array{Float32}, img2)
img3 = convert(Array{Float32}, img3)
img4 = convert(Array{Float32}, img4)
# img5 = convert(Array{Float32}, img5)
# img6 = convert(Array{Float32}, img6)
# img7 = convert(Array{Float32}, img7)
# img8 = convert(Array{Float32}, img8)
# img9 = convert(Array{Float32}, img9)
# img10 = convert(Array{Float32}, img10)
# img11 = convert(Array{Float32}, img11)
# img12 = convert(Array{Float32}, img12)
# img13 = convert(Array{Float32}, img13)
# img14 = convert(Array{Float32}, img14)
# img15 = convert(Array{Float32}, img15)
# img16 = convert(Array{Float32}, img16)
println("Time taken to convert to Float32: ", time() - start)
println(size(img1))
# img = img1
start = time()
img = cat(img1, img2, img3, img4, dims=3)#, img5, img6, img7, img8, dims=2)#, img9, img10, img11, img12, img13, img14, img15, img16, dims=2)
println("Time taken to concatenate: ", time() - start)
mat_image = OpenCV.Mat(img)
OpenCV.imwrite("assets/lenna_gaussian_before.png", mat_image)
schema = Dict(:name => "gaussian1D", :sigma => 1.6, :epsilon => 0.1725)
# convolve(reshape(img, size(img)...), schema, convert(Int32, imgHeight), 1)
out2, out1 = convolve(img, schema, imgHeight, 1)
schema1 = Dict(:name => "gaussian1D", :sigma => 1.6, :epsilon => 0.1725)
schema2 = Dict(:name => "gaussian1D", :sigma => 2.2627, :epsilon => 0.1725)
schema3 = Dict(:name => "gaussian1D", :sigma => 3.2, :epsilon => 0.1725)
schema4 = Dict(:name => "gaussian1D", :sigma => 4.5254, :epsilon => 0.1725)
schema5 = Dict(:name => "gaussian1D", :sigma => 6.4, :epsilon => 0.1725)
time_taken = 0
for i in 1:100
start_t = time()
out2, out1 = convolve(img, schema1, imgHeight, 0)
out2, out1 = convolve(img, schema2, imgHeight, 0)
out2, out1 = convolve(img, schema3, imgHeight, 0)
out2, out1 = convolve(img, schema4, imgHeight, 0)
out2, out1 = convolve(img, schema5, imgHeight, 0)
end_t = time()
global time_taken += end_t - start_t
if i == 100
mat_image1 = OpenCV.Mat(out1)
mat_image2 = OpenCV.Mat(out2)
OpenCV.imwrite("assets/gaussian_1.png", mat_image1)
OpenCV.imwrite("assets/gaussian_2.png", mat_image2)
end
end
println("NO L2 CACHE: Time taken per iteration: ", time_taken / 100, " seconds")
# # println(out)
# println(size(out))
# # save to assets/lenna_gaussian.png
# # OpenCV.imwrite("assets/lenna_gaussian.png", out)
# # uint8_array = UInt8.(round.(clamp.(out, 0, 1) .* 255))
# # Convert the uint8 array to an OpenCV Mat
# # out = reshape(out, 1, size(out, 1), size(out, 3))
mat_image1 = OpenCV.Mat(out1)
mat_image2 = OpenCV.Mat(out2)
OpenCV.imwrite("assets/lenna_gaussian_1.png", mat_image1)
OpenCV.imwrite("assets/lenna_gaussian_2.png", mat_image2)
# # println(out)