-
Notifications
You must be signed in to change notification settings - Fork 212
Image filters using 3-D convolution #165
Conversation
img = cv2.resize(img, (width , height)) | ||
|
||
#The pixels are extracted from the image | ||
pixels = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insert a new line before for loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this change
|
||
#function to apply convolution or multiply kernels | ||
def convolute(arr , height , width ,kernel): | ||
convoluted_matrix = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insert new line before for loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this change
img = Image.fromarray(combine) | ||
img.save('Funkyfilter.jpg') | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove new lines at the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make changes
|
||
for i in range(height): | ||
for j in range(width): | ||
combine[i ,j] = [int(r_convol[i][j]) , int(g_convol[i][j]) , int(b_convol[i][j])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove space before comma and put space after comma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this change
prod = np.multiply(temp,kernel) | ||
convoluted_matrix.append(np.sum(prod)) | ||
|
||
convoluted_matrix = (np.array(convoluted_matrix).reshape(height-3,width-3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put space after comma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this change
convoluted_matrix = [] | ||
for i in range(1,height-2): | ||
for j in range(1,width-2): | ||
temp = arr[i:i+3 , j:j+3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove space before comma and put space after comma
for i in range(1,height-2): | ||
for j in range(1,width-2): | ||
temp = arr[i:i+3 , j:j+3] | ||
prod = np.multiply(temp,kernel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put space after comma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this change
#function to apply convolution or multiply kernels | ||
def convolute(arr , height , width ,kernel): | ||
convoluted_matrix = [] | ||
for i in range(1,height-2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put space after comma
I will make the changes right away.
…On Thu, Aug 20, 2020, 12:24 PM Disha Sinha ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In Image-Processing/Image_filters_using_convolution/3D_convolve.py
<#165 (comment)>
:
> +'''b_kernel = np.array([0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11]).reshape(3,3)
+r_kernel = np.array([0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11]).reshape(3,3)
+g_kernel = np.array([0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11 , 0.11]).reshape(3,3)
+'''
+print("Enter 9 values for each of the streams")
+b_kernel = np.array(list(map(int, input("Enter the kernel to be applied to the blue stream").split()))).reshape(3,3)
+r_kernel = np.array(list(map(int, input("Enter the kernel to be applied to the red stream").split()))).reshape(3,3)
+g_kernel = np.array(list(map(int, input("Enter the kernel to be applied to the green stream").split()))).reshape(3,3)
+
+#Image is read and resized
+
+img = cv2.imread('path to image')
+img = cv2.resize(img, (width , height))
+
+#The pixels are extracted from the image
+pixels = []
Insert a new line before for loop
------------------------------
In Image-Processing/Image_filters_using_convolution/3D_convolve.py
<#165 (comment)>
:
> + g = []
+ r = []
+
+ for i in pixels:
+ b.append(i[0])
+ g.append(i[1])
+ r.append(i[2])
+
+#Each of the streams are resized
+r = np.array(r).reshape(height, width)
+b = np.array(b).reshape(height, width)
+g = np.array(g).reshape(height, width)
+
+#function to apply convolution or multiply kernels
+def convolute(arr , height , width ,kernel):
+ convoluted_matrix = []
Insert new line before for loop
------------------------------
In Image-Processing/Image_filters_using_convolution/3D_convolve.py
<#165 (comment)>
:
> +
+width = width - 3
+height = height - 3
+
+combine = np.zeros([height, width, 3], dtype=np.uint8)
+
+for i in range(height):
+ for j in range(width):
+ combine[i ,j] = [int(r_convol[i][j]) , int(g_convol[i][j]) , int(b_convol[i][j])]
+
+
+#The 3 matrices or streams are combined, and stored
+img = Image.fromarray(combine)
+img.save('Funkyfilter.jpg')
+
+
Remove new lines at the end
------------------------------
In Image-Processing/Image_filters_using_convolution/3D_convolve.py
<#165 (comment)>
:
> + convoluted_matrix = (np.array(convoluted_matrix).reshape(height-3,width-3))
+ return(convoluted_matrix)
+
+r_convol = convolute(r, height, width, r_kernel)
+g_convol = convolute(g, height, width, g_kernel)
+b_convol = convolute(b, height, width, b_kernel)
+
+
+width = width - 3
+height = height - 3
+
+combine = np.zeros([height, width, 3], dtype=np.uint8)
+
+for i in range(height):
+ for j in range(width):
+ combine[i ,j] = [int(r_convol[i][j]) , int(g_convol[i][j]) , int(b_convol[i][j])]
Remove space before comma and put space after comma
------------------------------
In Image-Processing/Image_filters_using_convolution/3D_convolve.py
<#165 (comment)>
:
> +
+#Each of the streams are resized
+r = np.array(r).reshape(height, width)
+b = np.array(b).reshape(height, width)
+g = np.array(g).reshape(height, width)
+
+#function to apply convolution or multiply kernels
+def convolute(arr , height , width ,kernel):
+ convoluted_matrix = []
+ for i in range(1,height-2):
+ for j in range(1,width-2):
+ temp = arr[i:i+3 , j:j+3]
+ prod = np.multiply(temp,kernel)
+ convoluted_matrix.append(np.sum(prod))
+
+ convoluted_matrix = (np.array(convoluted_matrix).reshape(height-3,width-3))
Put space after comma
------------------------------
In Image-Processing/Image_filters_using_convolution/3D_convolve.py
<#165 (comment)>
:
> + for i in pixels:
+ b.append(i[0])
+ g.append(i[1])
+ r.append(i[2])
+
+#Each of the streams are resized
+r = np.array(r).reshape(height, width)
+b = np.array(b).reshape(height, width)
+g = np.array(g).reshape(height, width)
+
+#function to apply convolution or multiply kernels
+def convolute(arr , height , width ,kernel):
+ convoluted_matrix = []
+ for i in range(1,height-2):
+ for j in range(1,width-2):
+ temp = arr[i:i+3 , j:j+3]
Remove space before comma and put space after comma
------------------------------
In Image-Processing/Image_filters_using_convolution/3D_convolve.py
<#165 (comment)>
:
> + b.append(i[0])
+ g.append(i[1])
+ r.append(i[2])
+
+#Each of the streams are resized
+r = np.array(r).reshape(height, width)
+b = np.array(b).reshape(height, width)
+g = np.array(g).reshape(height, width)
+
+#function to apply convolution or multiply kernels
+def convolute(arr , height , width ,kernel):
+ convoluted_matrix = []
+ for i in range(1,height-2):
+ for j in range(1,width-2):
+ temp = arr[i:i+3 , j:j+3]
+ prod = np.multiply(temp,kernel)
put space after comma
------------------------------
In Image-Processing/Image_filters_using_convolution/3D_convolve.py
<#165 (comment)>
:
> + r = []
+
+ for i in pixels:
+ b.append(i[0])
+ g.append(i[1])
+ r.append(i[2])
+
+#Each of the streams are resized
+r = np.array(r).reshape(height, width)
+b = np.array(b).reshape(height, width)
+g = np.array(g).reshape(height, width)
+
+#function to apply convolution or multiply kernels
+def convolute(arr , height , width ,kernel):
+ convoluted_matrix = []
+ for i in range(1,height-2):
Put space after comma
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#165 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AM3BEYKQTSCL7C4VVAR5YQ3SBTCBJANCNFSM4QDWIJUQ>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the changes requested earlier are yet to be made
img = cv2.resize(img, (width , height)) | ||
|
||
#The pixels are extracted from the image | ||
pixels = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this change
|
||
#function to apply convolution or multiply kernels | ||
def convolute(arr , height , width ,kernel): | ||
convoluted_matrix = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this change
for i in range(1,height-2): | ||
for j in range(1,width-2): | ||
temp = arr[i:i+3 , j:j+3] | ||
prod = np.multiply(temp,kernel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this change
Yes, I have made them |
I would want to know if I can submit scripts that I have written using the PyGame module and raise an issue for the same |
Great work @Namyalg ! |
Okay, will do.
…On Fri, Sep 4, 2020, 9:42 PM Ankit Dobhal ***@***.***> wrote:
I would want to know if I can submit scripts that I have written using the
PyGame module and raise an issue for the same
Great work @Namyalg <https://github.com/Namyalg> !
You can submit scripts written using pygame by raising new issue.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#165 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AM3BEYOORXGU5Y5AHWHCHN3SEEGWNANCNFSM4QDWIJUQ>
.
|
I would like to know if I have to make any changes to these scripts |
This script can be used to perform 3-D convolution on colored images.
Issue related to #93