diff --git a/Answers_Nathan/README.md b/Answers_Nathan/README.md new file mode 100644 index 0000000..2323722 --- /dev/null +++ b/Answers_Nathan/README.md @@ -0,0 +1,4 @@ +Name: Nathan Julian Dsouza +Reg ID: 241080016 +Branch: IT +College mail; njdsouza_b24@it.vjti.ac.in \ No newline at end of file diff --git a/Answers_Nathan/Task1.png b/Answers_Nathan/Task1.png new file mode 100644 index 0000000..1d3522c Binary files /dev/null and b/Answers_Nathan/Task1.png differ diff --git a/Answers_Nathan/Task2.png b/Answers_Nathan/Task2.png new file mode 100644 index 0000000..949ff99 Binary files /dev/null and b/Answers_Nathan/Task2.png differ diff --git a/Answers_Nathan/Task7.py b/Answers_Nathan/Task7.py new file mode 100644 index 0000000..730a6d7 --- /dev/null +++ b/Answers_Nathan/Task7.py @@ -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) \ No newline at end of file diff --git a/Answers_Nathan/Task7_Nathan.png b/Answers_Nathan/Task7_Nathan.png new file mode 100644 index 0000000..60e8354 Binary files /dev/null and b/Answers_Nathan/Task7_Nathan.png differ diff --git a/Answers_Nathan/task1.py b/Answers_Nathan/task1.py new file mode 100644 index 0000000..b0ca736 --- /dev/null +++ b/Answers_Nathan/task1.py @@ -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) \ No newline at end of file diff --git a/Answers_Nathan/task2.py b/Answers_Nathan/task2.py new file mode 100644 index 0000000..7b761c0 --- /dev/null +++ b/Answers_Nathan/task2.py @@ -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)}') + \ No newline at end of file diff --git a/Answers_Nathan/task7.png b/Answers_Nathan/task7.png new file mode 100644 index 0000000..955205b Binary files /dev/null and b/Answers_Nathan/task7.png differ