Skip to content

Commit b7327b3

Browse files
committed
Merge pull request arrayfire#739 from 9prady9/cmap_additions
ColorMap Option added to af::Window
2 parents c831bb5 + a8dfa17 commit b7327b3

12 files changed

Lines changed: 330 additions & 20 deletions

File tree

docs/details/graphics.dox

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
3+
\addtogroup graphics_func
4+
@{
5+
6+
A list of graphics functions to visualize data
7+
8+
\defgroup gfx_func_window Window Functions
9+
@{
10+
11+
Window creation, modification and destruction functions.
12+
13+
@}
14+
15+
\defgroup gfx_func_draw Rendering Functions
16+
@{
17+
18+
Rendering functions to draw images, plots etc.
19+
20+
@}
21+
22+
@}
23+
*/

examples/graphics/conway_pretty.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ int main(int argc, char *argv[])
4040

4141
af::Window simpleWindow(512, 512, "Conway's Game Of Life - Current State");
4242
af::Window prettyWindow(512, 512, "Conway's Game Of Life - Visualizing States");
43+
simpleWindow.setPos(25, 25);
44+
prettyWindow.setPos(125, 15);
4345

4446
int frame_count = 0;
4547

@@ -50,7 +52,7 @@ int main(int argc, char *argv[])
5052

5153
array display = tile(state, 1, 1, 3, 1);
5254

53-
while(!simpleWindow.close() || !prettyWindow.close()) {
55+
while(!simpleWindow.close() && !prettyWindow.close()) {
5456
af::timer delay = timer::start();
5557

5658
if(!simpleWindow.close()) simpleWindow.image(state);

examples/graphics/fractal.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ int main(int argc, char **argv)
7373
info();
7474
printf("** ArrayFire Fractals Demo **\n");
7575
af::Window wnd("Fractal Demo");
76+
wnd.setColorMap(AF_COLORMAP_SPECTRUM);
7677

7778
float center[] = {-0.5, 0};
7879
// Keep zomming out for each frame
79-
for (int zoom = 1000; zoom > 10; zoom -= 5) {
80+
for (int zoom = 1000; zoom > 100; zoom -= 1) {
8081
// Generate the grid at the current zoom factor
8182
array c = complex_grid(WIDTH, HEIGHT, zoom, center);
8283

examples/image_processing/brain_segmentation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ array segment_volume(array A, int k)
9191
void brain_seg(bool console)
9292
{
9393
af::Window wnd("Brain Segmentation Demo");
94+
wnd.setColorMap(AF_COLORMAP_HEAT);
9495

9596
double time_total = 30; // run for N seconds
9697

examples/image_processing/optical_flow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static void diffs(array& Ix, array& Iy, array& It, array I1, array I2)
3838
static void optical_flow_demo(bool console)
3939
{
4040
af::Window wnd("Horn-Schunck Optical Flow Demo");
41+
wnd.setColorMap(AF_COLORMAP_COLORS);
4142

4243
double time_total = 10; // run for N seconds
4344

include/af/defines.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,16 @@ typedef enum {
285285
AF_NORM_EUCLID = AF_NORM_VECTOR_2, ///< The default. Same as AF_NORM_VECTOR_2
286286
} af_norm_type;
287287

288+
typedef enum {
289+
AF_COLORMAP_DEFAULT = 0, ///< Default grayscale map
290+
AF_COLORMAP_SPECTRUM= 1, ///< Spectrum map
291+
AF_COLORMAP_COLORS = 2, ///< Colors
292+
AF_COLORMAP_RED = 3, ///< Red hue map
293+
AF_COLORMAP_MOOD = 4, ///< Mood map
294+
AF_COLORMAP_HEAT = 5, ///< Heat map
295+
AF_COLORMAP_BLUE = 6 ///< Blue hue map
296+
} af_colormap;
297+
288298
// Below enum is purely added for example purposes
289299
// it doesn't and shoudn't be used anywhere in the
290300
// code. No Guarantee's provided if it is used.
@@ -309,6 +319,7 @@ namespace af
309319
typedef af_conv_mode convMode;
310320
typedef af_conv_domain convDomain;
311321
typedef af_mat_prop matProp;
322+
typedef af_colormap ColorMap;
312323
typedef af_norm_type normType;
313324
}
314325

0 commit comments

Comments
 (0)