diff options
author | scuri <scuri> | 2008-10-17 06:10:15 +0000 |
---|---|---|
committer | scuri <scuri> | 2008-10-17 06:10:15 +0000 |
commit | 5a422aba704c375a307a902bafe658342e209906 (patch) | |
tree | 5005011e086bb863d8fb587ad3319bbec59b2447 /test/lua/analyze.lua |
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'test/lua/analyze.lua')
-rw-r--r-- | test/lua/analyze.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/lua/analyze.lua b/test/lua/analyze.lua new file mode 100644 index 0000000..7f06496 --- /dev/null +++ b/test/lua/analyze.lua @@ -0,0 +1,28 @@ +require"imlua" +require"imlua_process" + +local filename = "lena.jpg" + +local image = im.FileImageLoad(filename) +local gray = im.ImageCreate(image:Width(), image:Height(), im.GRAY, image:DataType()) +local binary = im.ImageCreate(image:Width(), image:Height(), im.BINARY, image:DataType()) +local region = im.ImageCreate(image:Width(), image:Height(), im.GRAY, im.USHORT) + +-- make it grayscale +im.ConvertColorSpace(image, gray) +gray:Save("lena_gray.jpg", "JPEG") + +-- make it binary +im.ProcessSliceThreshold(gray, binary, 0, 128) +binary:Save("lena_binary.jpg", "JPEG") + +local count = im.AnalyzeFindRegions(binary, region, 4, 1) +print("regions: ", count) + +local region2 = im.ImageCreate(image:Width(), image:Height(), im.GRAY, im.BYTE) +im.ConvertDataType(region, region2, 0, 0, 0, 0) + +local region3 = im.ImageCreate(image:Width(), image:Height(), im.MAP, im.BYTE) +im.ConvertColorSpace(region2, region3) +region3:SetPalette(im.PaletteHighContrast(), 256) +region3:Save("lena_region.gif", "GIF") |