diff --git a/Tasks/Task1.md b/Tasks/Task1.md deleted file mode 100644 index ee5cdb6..0000000 --- a/Tasks/Task1.md +++ /dev/null @@ -1,6 +0,0 @@ -## Task 1: - -You have have been given an image with a white canvas containing few non white pixels. The task is to use OpenCV to **find the number of non white pixels and also return the positions** of the pixels you have found. - - -#### Link for the image: https://drive.google.com/file/d/1OTYYn3tJJ_iT4f0fUmPSnl71gYHjRphl/view?usp=drive_link diff --git a/Tasks/Task1.png b/Tasks/Task1.png new file mode 100644 index 0000000..1d3522c Binary files /dev/null and b/Tasks/Task1.png differ diff --git a/Tasks/Task1.py b/Tasks/Task1.py new file mode 100644 index 0000000..03d55f3 --- /dev/null +++ b/Tasks/Task1.py @@ -0,0 +1,32 @@ +# ## Task 1: + +# You have have been given an image with a white canvas containing few non white pixels. The task is to use OpenCV to **find the number of non white pixels and also return the positions** of the pixels you have found. + + +# #### Link for the image: https://drive.google.com/file/d/1OTYYn3tJJ_iT4f0fUmPSnl71gYHjRphl/view?usp=drive_link +import cv2 +import numpy as np + +img1 = cv2.imread("/home/rudrakshi/projectxopenCV/Xplore2.0/Tasks/Task1.png") +# print(img1.shape) +# pixel = img1[50,450] +# print(pixel) +# cv.imshow("img1" , img1) +# cv.waitKey(0) +# cv.destroyAllWindows() + +white = [255,255,255] +count = 0 +for y in range (img1.shape[0]): + for x in range (img1.shape[1]): + if(img1[y,x] != [255,255,255]).all(): + print("coordinate are : (",y,x,")" + ) + count=count+1 + + +print("The total number of non-white pixels are ", count) + + + + diff --git a/Tasks/tempCodeRunnerFile.py b/Tasks/tempCodeRunnerFile.py new file mode 100644 index 0000000..0e752f8 --- /dev/null +++ b/Tasks/tempCodeRunnerFile.py @@ -0,0 +1,3 @@ +cv.imshow("img1" , img1) +# cv.waitKey(0) +# cv.destroyAllWindows() \ No newline at end of file