mightymandel v16

GPU-based Mandelbrot set explorer

blob_set.c File Reference

(v16)

Blob extraction and disjoint collection of blobs (implementation). More...

#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "blob_set.h"
#include "utility.h"
+ Include dependency graph for blob_set.c:

Go to the source code of this file.

Data Structures

struct  blob_set_node
 Singly-linked list node for blobs. More...
struct  blob_set
 A disjoint collection of blobs. More...
struct  label
 Label structure for blob extraction. More...
struct  uf
 Union-find node. More...
struct  ufs
 Union-find set. More...

Functions

struct blob_setblob_set_new ()
 Create a new empty blob set.
void blob_set_delete (struct blob_set *s)
 Delete a blob set.
void blob_set_insert (struct blob_set *s, const struct blob *blob)
 Insert a blob into a blob set.
bool blob_set_contains (const struct blob_set *s, const struct blob *blob)
 Check if a blob is contained in a blob set.
int cmp_blob_count_desc (const void *a, const void *b)
 Compare blob counts. Larger counts compare earlier.
int cmp_blob_error_desc (const void *a, const void *b)
 Compare blob errors. Larger errors compare earlier.
int cmp_label (const void *a, const void *b)
 Compare labels.
void uf_singleton (struct ufs *ufs, int x)
 Union-find singleton.
int uf_find (struct ufs *ufs, int x)
 Union-find find.
void uf_union (struct ufs *ufs, int x, int y)
 Union-find union.
struct blobfind_blobs0 (int *blob_count, int width, int height, const float *glitched, enum blob_strategy strategy, int i0, int i1, int j0, int j1)
 Extract blobs from an image region using a strategy.
struct blobfind_blobs1 (int *blob_count, int width, int height, const float *glitched)
 Extract blobs from a whole image using blob_boolean strategy.
struct blobfind_blobs2 (int *blob_count, int width, int height, const float *glitched, const struct blob *blob)
 Extract sub-blobs from an image using blob_positive strategy.

Detailed Description

Blob extraction and disjoint collection of blobs (implementation).

Definition in file blob_set.c.


Data Structure Documentation

struct blob_set_node

Singly-linked list node for blobs.

Definition at line 23 of file blob_set.c.

+ Collaboration diagram for blob_set_node:
Data Fields
struct blob blob Item contents.
struct blob_set_node * next Next item in the list.
struct blob_set

A disjoint collection of blobs.

Definition at line 31 of file blob_set.c.

+ Collaboration diagram for blob_set:
Data Fields
struct blob_set_node * set A singly-linked list.
struct label

Label structure for blob extraction.

Definition at line 96 of file blob_set.c.

Data Fields
float error
int i
int j
int label
struct uf

Union-find node.

Definition at line 115 of file blob_set.c.

Data Fields
int parent
int rank
struct ufs

Union-find set.

Definition at line 123 of file blob_set.c.

+ Collaboration diagram for ufs:
Data Fields
int height
struct label * labels
struct uf * nodes
int width

Function Documentation

bool blob_set_contains ( const struct blob_set s,
const struct blob blob 
)

Check if a blob is contained in a blob set.

Parameters
sA blob set.
blobA blob.
Returns
true if the blob is in the set, false otherwise.

Definition at line 61 of file blob_set.c.

References blob_set_node::blob, blob::count, blob::i, blob::j, blob_set_node::next, and blob_set::set.

Referenced by find_ref().

+ Here is the caller graph for this function:

void blob_set_delete ( struct blob_set s)

Delete a blob set.

Parameters
sA blob set.

Definition at line 39 of file blob_set.c.

References blob_set_node::next, and blob_set::set.

Referenced by fpxx_start().

+ Here is the caller graph for this function:

void blob_set_insert ( struct blob_set s,
const struct blob blob 
)

Insert a blob into a blob set.

Parameters
sA blob set.
blobA blob.

Definition at line 51 of file blob_set.c.

References blob_set_node::blob, blob::count, blob::i, blob::j, blob::label, blob_set_node::next, and blob_set::set.

Referenced by find_ref().

+ Here is the caller graph for this function:

struct blob_set* blob_set_new ( )
read

Create a new empty blob set.

Returns
A blob set.

Definition at line 35 of file blob_set.c.

Referenced by fpxx_start().

+ Here is the caller graph for this function:

int cmp_blob_count_desc ( const void *  a,
const void *  b 
)

Compare blob counts. Larger counts compare earlier.

Definition at line 75 of file blob_set.c.

References blob::count.

Referenced by find_blobs0().

+ Here is the caller graph for this function:

int cmp_blob_error_desc ( const void *  a,
const void *  b 
)

Compare blob errors. Larger errors compare earlier.

Definition at line 84 of file blob_set.c.

References blob::error.

Referenced by find_blobs0().

+ Here is the caller graph for this function:

int cmp_label ( const void *  a,
const void *  b 
)

Compare labels.

Definition at line 106 of file blob_set.c.

References label::label.

Referenced by find_blobs0().

+ Here is the caller graph for this function:

struct blob* find_blobs0 ( int *  blob_count,
int  width,
int  height,
const float glitched,
enum blob_strategy  strategy,
int  i0,
int  i1,
int  j0,
int  j1 
)
read

Extract blobs from an image region using a strategy.

Parameters
blob_countThe number of extracted blobs is stored here.
widthThe glitch count image width.
heightThe glitch count image height.
glitchedThe glitch count image.
strategyThe strategy to use.
i0The lower i coordinate of the image region (eg: 0).
i1The upper i coordinate of the image region (eg: width).
j0The lower j coordinate of the image region (eg: 0).
j1The upper j coordinate of the image region (eg: height).
Returns
An array of blobs, sorted by count (blob_boolean) or glitch count (blob_positive), largest first.

Definition at line 170 of file blob_set.c.

References blob_boolean, cmp_blob_count_desc(), cmp_blob_error_desc(), cmp_label(), blob::count, blob::error, label::error, ufs::height, blob::i, label::i, blob::j, label::j, blob::label, label::label, ufs::labels, max(), blob::max_i, blob::max_j, min(), blob::min_i, blob::min_j, ufs::nodes, uf_find(), uf_singleton(), uf_union(), and ufs::width.

Referenced by find_blobs1(), and find_blobs2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

struct blob* find_blobs1 ( int *  blob_count,
int  width,
int  height,
const float glitched 
)
read

Extract blobs from a whole image using blob_boolean strategy.

Parameters
blob_countThe number of extracted blobs is stored here.
widthThe glitch count image width.
heightThe glitch count image height.
glitchedThe glitch count image.
Returns
An array of blobs, sorted by count, largest first.

Definition at line 299 of file blob_set.c.

References blob_boolean, and find_blobs0().

Referenced by find_ref().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

struct blob* find_blobs2 ( int *  blob_count,
int  width,
int  height,
const float glitched,
const struct blob blob 
)
read

Extract sub-blobs from an image using blob_positive strategy.

Parameters
blob_countThe number of extracted blobs is stored here.
widthThe glitch count image width.
heightThe glitch count image height.
glitchedThe glitch count image.
blobThe blob determines the region to search within.
Returns
An array of sub-blobs, sorted by glitch count, largest first.

Definition at line 303 of file blob_set.c.

References blob_positive, find_blobs0(), blob::max_i, blob::max_j, blob::min_i, and blob::min_j.

Referenced by find_ref().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int uf_find ( struct ufs ufs,
int  x 
)

Union-find find.

Definition at line 141 of file blob_set.c.

References ufs::nodes, and uf::parent.

Referenced by find_blobs0(), and uf_union().

+ Here is the caller graph for this function:

void uf_singleton ( struct ufs ufs,
int  x 
)

Union-find singleton.

Definition at line 133 of file blob_set.c.

References ufs::nodes, uf::parent, and uf::rank.

Referenced by find_blobs0().

+ Here is the caller graph for this function:

void uf_union ( struct ufs ufs,
int  x,
int  y 
)

Union-find union.

Definition at line 152 of file blob_set.c.

References ufs::nodes, uf::parent, uf::rank, and uf_find().

Referenced by find_blobs0().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: