Skip to content
Snippets Groups Projects
Commit 36bc8d0f authored by ivan.rigo's avatar ivan.rigo
Browse files

Ex1 S3 found his daddy

parent 2992e103
No related branches found
No related tags found
No related merge requests found
......@@ -23,9 +23,8 @@ def show_img(img: Img) -> None:
def xcorr(img: Img, kernel: Img) -> Img:
kLen = int(kernel.shape[0]/2)
yMax = img.shape[0]
xMax = img.shape[1]
print(yMax)
xMax = img.shape[0]
yMax = img.shape[1]
xcorrRes = np.zeros((img.shape[0],img.shape[1]))
iteNp = np.nditer(img,flags=["multi_index"])
while not iteNp.finished :
......@@ -41,19 +40,18 @@ def xcorr(img: Img, kernel: Img) -> Img:
for xK in range(kernel.shape[0]):
for yK in range(kernel.shape[1]):
if xCorner + xK >= xMax or xCorner + xK < 0 or yCorner + yK < 0 or yCorner + yK >= yMax :
regToApply[xK,yK] = 120
regToApply[xK,yK] = 123
else:
print(str(xCorner + xK) + " | " + str(yCorner + yK))
regToApply[xK,yK] = img[xCorner + xK, yCorner + yK]
xcorrRes[x,y] = np.sum(np.multiply(regToApply,kernel))
iteNp.iternext()
return xcorrRes
#fog, axe = plt.subplots(2)
fog, axe = plt.subplots(2)
imgToModify = load_img("lena.png")
#axe[0].imshow(imgToModify,cmap="gray",vmin=0,vmax=256)
axe[0].imshow(imgToModify,cmap="gray",vmin=0,vmax=256)
kern = np.zeros((3,3),dtype=np.uint8)
kern[0,1] = 1
imgRes = xcorr(imgToModify, kern)
#axe[1].imshow(imgRes,cmap="gray",vmin=0,vmax=256)
#plt.show()
axe[1].imshow(imgRes,cmap="gray",vmin=0,vmax=256)
plt.show()
#show_img(imgRes)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment