Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menù personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2023-24 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

hw8 recupero consigli

G
Gabriel_Guerra (690 points)
1 2 7
in HW8 by (690 points)
recategorized by
Buonasera, se mi potreste dare qualche consiglio di come iniziare il HW8 di recupero?

Vi ringrazio tanto
707 views

2 Answers

J
Jad (2690 points)
6 27 38
by (2.7k points)
I would suggest:

1_ loop through the image and whenever you find a pixel whose color is different from the background color, add 4 to the counter(since each pair of lines split the image into 4 parts) and then go through the pair of lines and delete them . Like this the counter will represent number of patches

for the second part where you have to recursively get the colors of lines and arrange them in n*1 image , I'm still thinking about it, Sorry ,>
G
Gabriel_Guerra (690 points)
1 2 7
by (690 points)
Thank you so much Jad, I'm also thinking about the 2d part, I'll write you when I reach the answer
rinverardigalli (1630 points)
4 8 17
by (1.6k points)
did you find a solution for the second part of the problem? i'm still struggling a bit :/
l
lorenzo.m (250 points)
0 1 3
by (250 points)
edited by
for the second part where you have to return the list of the color hierarchy, I suggest recursively tracing all the lots using the recursive algorithm called 'post-order-traversal' on the internet you will find a lot of information about it. currently i have implemented it and it work but I still haven't been able to get it to work in cases where the lots have sides shorter than 2 pixels. To make the concept easier, try looking at the image as a quaternary tree. This algortim if well implemented, it will not only return the list of color hierarchy but also che patches count.
rinverardigalli (1630 points)
4 8 17
by (1.6k points)
there shouldn't be any cases where the lots have sides smaller than 2 pixels, if i read the text correctly
l
lorenzo.m (250 points)
0 1 3
by (250 points)
you are right thanks. I hadn't read everything. in this case it also works for secret tests. Since I was assuming that in secret tests they would include sides shorter than 2
rinverardigalli (1630 points)
4 8 17
by (1.6k points)
Did you build a binary tree in order to implement the algorithm?
l
lorenzo.m (250 points)
0 1 3
by (250 points)
No, it is not necessary, but remember that the image is not a binary tree, but a quaternary tree, the rules are still the same.
rinverardigalli (1630 points)
4 8 17
by (1.6k points)
yeah sorry i meant tree, binary was not intended
L
Lorenzo Scalera (2760 points)
4 8 12
by (2.8k points)
what do u mean with "go through the pair of lines and delete them"?
G
Gabriel_Guerra (690 points)
1 2 7
by (690 points)

CIao @lorenzo.m  ti ho scritto un messaggio laugh

J
Jad (2690 points)
6 27 38
by (2.7k points)

You have the BIG SPLITTING LINE. This will split the patch into 4 sections. now inside each section starting from section 4 ,you look if there exist another relatively big splitting line. If so, you repeat the process (i.e, recursion).

This is how I would approach part 2 of the HW, hope it works for you
 

C
Carda (360 points)
0 1 6
by (360 points)
I tried it and in my case it was too slow