Skip to content

Comments

Task 2#5

Open
gitfrandu4 wants to merge 1 commit intomainfrom
task-2
Open

Task 2#5
gitfrandu4 wants to merge 1 commit intomainfrom
task-2

Conversation

@gitfrandu4
Copy link
Owner

Script:

width = 800
height = 600

n_channels = 3

rectangle_size = 200

# Create a blank image with three channels
mondrian_img = np.zeros((height,width,n_channels), dtype = np.uint8)

# We can also set the color of the image by setting the values of the pixels in each channel
blue = (0,0,255)
red = (255,0,0)
white = (255,255,255)
yellow = (255,255,0)
black = (0,0,0)

mondrian_rectangles = [
    [(0, 0, 200, 200, yellow),
     (200, 0, 400, 200, blue),
     (400, 0, 800, 200, white)],
    [(0, 200, 300, 400, red),
     (300, 200, 800, 400, yellow)],
    [(0, 400, 800, 550, blue)],
    [(0, 550, 100, 600, white)],
    [(100, 550, 600, 600, yellow)],
    [(600, 550, 800, 600, red)]
]

thickness = 30

for row in mondrian_rectangles:
    for rect in row:
        cv2.rectangle(mondrian_img, (rect[0], rect[1]), (rect[2], rect[3]), black, thickness)
        cv2.rectangle(mondrian_img, (rect[0], rect[1]), (rect[2], rect[3]), rect[4], -1)

plt.imshow(mondrian_img) 
plt.axis('off')
plt.show()

Ejemplo:

image

@gitfrandu4 gitfrandu4 changed the title add task 2 Task 2 Sep 16, 2024
@gitfrandu4 gitfrandu4 requested a review from DerKom September 16, 2024 17:40
@gitfrandu4 gitfrandu4 self-assigned this Sep 16, 2024
@gitfrandu4 gitfrandu4 added the enhancement New feature or request label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant