Skip to content

Commit

Permalink
Partial submission ready
Browse files Browse the repository at this point in the history
  • Loading branch information
dnery committed Jun 12, 2017
1 parent 3458868 commit 5b292b3
Show file tree
Hide file tree
Showing 2,024 changed files with 805,928 additions and 39,559 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
all:
$(MAKE) -C igraph
g++ image_to_graph.cc -o image_to_graph -Wall -ligraph `pkg-config --cflags --libs opencv`

config:
cd igraph && ./configure && cd ..

.PHONY: clean allclean

clean:
rm -f image_to_graph

allclean:
$(MAKE) -C igraph clean
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
You'll need OpenCV for this. The igraph package is also needed and it's included.

Compile:
```
g++ image_to_graph.cc -o image_to_graph -Wall -ligraph -fopenmp `pkg-config --cflags --libs opencv`
make config
make
```

Run stack:
```
./image_to_graph lena.jpg && python display_graph.py
./image_to_graph <input_image> && python display_graph.py <input_image>
```
32 changes: 28 additions & 4 deletions display_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import matplotlib.pyplot as pl
import networkx as nx
import numpy as np
import sys
import cv2

print('Done.')
##############


## Build graph
print('Rebuilding graph... ', end='', flush=True)

Expand All @@ -19,15 +20,38 @@

print('Done.')

## Build layout
print('Making layout... ', end='', flush=True)

layout = {}
for row in range(rows):
for col in range(cols):
layout[row*cols+col] = [col,rows-row]

nx.draw_networkx_edges(G, pos=layout)
pl.savefig('image_to_graph.out.png')

print('Done.')

## Check results
nx.draw_networkx_edges(G, pos=layout)
pl.show()
## Display results
print('Displaying (\'q\' to quit)... ', end='', flush=True)

imga = cv2.imread(sys.argv[1], cv2.IMREAD_GRAYSCALE)
imgb = cv2.imread('image_to_graph.out.png', cv2.IMREAD_GRAYSCALE)

ha,wa = imga.shape[:2]
hb,wb = imgb.shape[:2]

output = np.zeros((max(ha,hb),wa+wb), np.uint8) + 255
output[:ha,:wa] = imga
output[:hb,wa:wa+wb] = imgb

cv2.imshow('Grayscale Image to Complex Network (\'q\' to quit)', output)

while(True):
if cv2.waitKey(0) == ord('q'):
break

cv2.destroyAllWindows()

print('Done.')
2 changes: 2 additions & 0 deletions igraph/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Gabor Csardi <[email protected]>
Tamas Nepusz <[email protected]>
340 changes: 340 additions & 0 deletions igraph/COPYING

Large diffs are not rendered by default.

Empty file added igraph/ChangeLog
Empty file.
Loading

0 comments on commit 5b292b3

Please sign in to comment.