Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Answers_Nathan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Name: Nathan Julian Dsouza
Reg ID: 241080016
Branch: IT
College mail; njdsouza_b24@it.vjti.ac.in
Binary file added Answers_Nathan/Task1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Answers_Nathan/Task2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions Answers_Nathan/Task7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import cv2 as cv
import numpy as np

#Just to get the dimensions
img = cv.imread(r'H:\Engineering 2024\Coding\ProjectX\Tasks to be done\OpenCV-Clone\Answers_Nathan\task7.png')
print(img.shape)

height = img.shape[0]*3
width = img.shape[1]*3

img = np.ones((height, width, 3), dtype=np.uint8) * 255
img[:] = (255, 200, 173)

#ground
cv.rectangle(img, (0, height), (width, height-20), (0, 100, 0), -1)
#house
cv.rectangle(img, (width//3, height-21), (2*width//3, height-200), (0, 75, 128), -1)
#door
cv.rectangle(img, (width//2-30, height-21), (width//2+30, height-100), (230, 255, 255), -1)
#window
cv.rectangle(img, (width//3+10, height-150), (width//3+60, height-100), (230, 255, 255), -1)
cv.rectangle(img, (2*width//3-60, height-150), (2*width//3-10, height-100), (230, 255, 255), -1)

#roof
pt1 = (2*width//3+30, height-200)
pt2 = (width//3-30, height-200)
pt3 = (width//2, height-280)
cv.circle(img, pt1, 0, (0,255,255), -1)
cv.circle(img, pt2, 0, (0,255,255), -1)
cv.circle(img, pt3, 0, (0,255,255), -1)
triangle_cnt = np.array( [pt1, pt2, pt3] )
cv.drawContours(img, [triangle_cnt], 0, (10,75,225), -1)

#text
cv.putText(img, 'My House Eh', (width//3, height//2), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 1, cv.LINE_AA)
#Sun
cv.circle(img, (width-70, 100), 30, (0,245,245), -1)

cv.imwrite('Task7_Nathan.png', img)
cv.waitKey(0)
Binary file added Answers_Nathan/Task7_Nathan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions Answers_Nathan/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import cv2 as cv
import numpy as np

img = cv.imread('H:\Engineering 2024\Coding\ProjectX\Answers_Nathan\OpenCV-Clone\Answers_Nathan\Task1.png')

def apply_grayscale(image):
gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
return gray

img2 = apply_grayscale(img)

count = 0

for i in range(img2.shape[0]):
for j in range(img2.shape[1]):
if img2[i][j] != 255:
count += 1
print(f"Pixel {count} at (", i, ",", j, ") is not white.")

print("The number of non-white pixels in the image is: ", count)
34 changes: 34 additions & 0 deletions Answers_Nathan/task2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import cv2 as cv
import numpy as np

img = cv.imread(r'H:\Engineering 2024\Coding\ProjectX\Answers_Nathan\OpenCV-Clone\Answers_Nathan\Task2.png', cv.IMREAD_GRAYSCALE)

morse = ''
for i in range(img.shape[0]):
for j in range(img.shape[1]):
if img[i][j] == 255:
morse = morse + '.'
elif img[i][j] == 0:
morse = morse + '-'
else:
morse = morse + ' '


print(morse)

def morse_reader(morse):
morse_dict = {
'.-': 'A', '-...': 'B', '-.-.': 'C', '-..': 'D',
'.': 'E', '..-.': 'F', '--.': 'G', '....': 'H',
'..': 'I', '.---': 'J', '-.-': 'K', '.-..': 'L',
'--': 'M', '-.': 'N', '---': 'O', '.--.': 'P',
'--.-': 'Q', '.-.': 'R', '...': 'S', '-': 'T',
'..-': 'U', '...-': 'V', '.--': 'W', '-..-': 'X',
'-.--': 'Y', '--..': 'Z'
}

return ''.join(morse_dict.get(code) for code in morse.strip().split())


print(f'The Morse Code gives us: {morse_reader(morse)}')

Binary file added Answers_Nathan/task7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.