Function iaglblshow

namespace:morph
page:iaglblshow

Synopse

Apply a random color table to a gray-scale image.

  • Y = iaglblshow(X, border=0.0)
    • Y: Image
    • X: Image Labeled image.
    • border: Boolean If true, draw a white border around each labeled region.
01. from numpy import *
02. from numpy.random import rand
03. 
04. def iaglblshow(X, border=0.0):
05.     from iastats import iastats
06.     from iaconcat import iaconcat
07. 
08.     iain = iastats(X,'min')
09.     iaax = iastats(X,'max')
10.     ncolors = iaax - iain + 1
11.     R = rand(ncolors)*255
12.     G = rand(ncolors)*255
13.     B = rand(ncolors)*255
14.     if iain == 0:
15.        R[0],G[0],B[0] = 0,0,0
16.     r=resize(take(R.astype(uint8), X.flat - iain),X.shape)
17.     g=resize(take(G.astype(uint8), X.flat - iain),X.shape)
18.     b=resize(take(B.astype(uint8), X.flat - iain),X.shape)
19.     Y=iaconcat('d',r,g,b)
20.     return Y

Examples

1. from ia870 import ialabel, iaglblshow
2. 
3. f = adread('blob3.tif')
4. g = ialabel(f)
5. adshow(f)
6. adshow(iaglblshow(g))