Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
Quadtree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fabian.troller
Quadtree
Commits
fdf13216
Commit
fdf13216
authored
4 years ago
by
poulpe
Browse files
Options
Downloads
Patches
Plain Diff
[Update] Help from Scott Birner for quadtree_position
parent
56261beb
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
main.c
+9
-2
9 additions, 2 deletions
main.c
pgm_io.c
+2
-2
2 additions, 2 deletions
pgm_io.c
pgm_io.h
+2
-2
2 additions, 2 deletions
pgm_io.h
quadtree.c
+4
-2
4 additions, 2 deletions
quadtree.c
quadtree.h
+1
-1
1 addition, 1 deletion
quadtree.h
with
18 additions
and
9 deletions
main.c
+
9
−
2
View file @
fdf13216
...
...
@@ -7,14 +7,21 @@
#include
"quadtree.h"
#include
"Matrix.h"
int
main
(
int
argc
,
char
**
argvs
)
int
main
()
{
pgm
*
p
=
malloc
(
1
*
sizeof
(
pgm
));
pgm_read_from_file
(
p
,
"buzz.pgm"
);
uint32_t
val
=
quadtree_get_depth_from_image_size
(
p
->
pixels
.
col
,
p
->
pixels
.
lin
);
uint32_t
val
=
quadtree_get_depth_from_image_size
(
p
->
pixels
.
col
);
printf
(
"Depth : %u
\n
"
,
val
);
node
*
tree
=
quadtree_tree_create
(
val
);
matrix_print
(
p
->
pixels
);
quadtree_matrix2tree
(
&
p
->
pixels
,
tree
);
quadtree_print
(
tree
,
1
,
"|"
);
matrix_destroy
(
&
p
->
pixels
);
quadtree_tree_destroy
(
&
tree
);
free
(
p
);
...
...
This diff is collapsed.
Click to expand it.
pgm_io.c
+
2
−
2
View file @
fdf13216
...
...
@@ -14,7 +14,7 @@
* @param filename = the file path of the image to read
* @return pgm_error
*/
pgm_error
pgm_read_from_file
(
pgm
*
p
,
c
har
*
filename
)
pgm_error
pgm_read_from_file
(
pgm
*
p
,
c
onst
char
*
const
filename
)
{
int
sizex
=
0
;
int
sizey
=
0
;
...
...
@@ -127,7 +127,7 @@ pgm_error pgm_duplicate(char *filename,char *newfile)
* @param gray_scale = the gray scale max in file returned by pointed value
* @return pgm_error
*/
pgm_error
pgm_read_header
(
c
har
*
filename
,
int
*
sizex
,
int
*
sizey
,
int
*
gray_scale
)
pgm_error
pgm_read_header
(
c
onst
char
*
const
filename
,
int
*
sizex
,
int
*
sizey
,
int
*
gray_scale
)
{
FILE
*
f
;
f
=
fopen
(
filename
,
"r"
);
...
...
This diff is collapsed.
Click to expand it.
pgm_io.h
+
2
−
2
View file @
fdf13216
...
...
@@ -18,9 +18,9 @@ int32_t max;
matrix
pixels
;
}
pgm
;
pgm_error
pgm_read_from_file
(
pgm
*
p
,
c
har
*
filename
);
pgm_error
pgm_read_from_file
(
pgm
*
p
,
c
onst
char
*
const
filename
);
pgm_error
pgm_write_from_file
(
pgm
*
p
,
char
*
filename
);
pgm_error
pgm_duplicate
(
char
*
filename
,
char
*
newfile
);
pgm_error
pgm_read_header
(
c
har
*
filename
,
int
*
sizex
,
int
*
sizey
,
int
*
gray_scale
);
pgm_error
pgm_read_header
(
c
onst
char
*
const
filename
,
int
*
sizex
,
int
*
sizey
,
int
*
gray_scale
);
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
quadtree.c
+
4
−
2
View file @
fdf13216
...
...
@@ -5,7 +5,7 @@ bool quadtree_is_leaf(node *nd)
return
(
NULL
==
nd
->
child
[
0
]);
}
int32_t
quadtree_get_depth_from_image_size
(
int32_t
sizex
,
int
sizey
)
int32_t
quadtree_get_depth_from_image_size
(
int32_t
sizex
)
{
return
(
int32_t
)
log2
(
sizex
);
}
...
...
@@ -104,7 +104,9 @@ node *quadtree_position(int32_t li, int32_t col, node *a, int32_t d)
node
*
crt
=
a
;
do
{
int32_t
index
=
666666
;
//choisir le sous-cadran de <li> et <co>
int32_t
ligne
=
(
li
>>
d
)
&
1
;
// Permet de sélectionne le bit à considérer en fonction de la profondeur; Exemple: 10 >> 1 = 1
int32_t
colonne
=
(
col
>>
d
)
&
1
;
//Exemple: 10 >> 1 = 1;
int32_t
index
=
ligne
<<
1
|
colonne
;
//Exemple: 1<<1 = 10 | 1(col) = 11=>3
crt
=
crt
->
child
[
index
];
d
--
;
}
while
(
!
quadtree_is_leaf
(
crt
));
...
...
This diff is collapsed.
Click to expand it.
quadtree.h
+
1
−
1
View file @
fdf13216
...
...
@@ -18,7 +18,7 @@ node* quadtree_tree_create(int32_t depth);
bool
quadtree_is_leaf
(
node
*
nd
);
int32_t
quadtree_get_depth_from_image_size
(
int32_t
sizex
,
int
sizey
);
int32_t
quadtree_get_depth_from_image_size
(
int32_t
sizex
);
int32_t
quadtree_max
(
int32_t
x
,
int32_t
y
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment