summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorscuri <scuri>2009-08-18 02:21:01 +0000
committerscuri <scuri>2009-08-18 02:21:01 +0000
commit77a4608ee1f828ed70ec58588f0229cd57758148 (patch)
treeb1550da93d53331715c200f1acf8a7c1b2ff7be9 /test
parente2726d7bef3b0a1684011e558cb68ca99cfecd75 (diff)
*** empty log message ***
Diffstat (limited to 'test')
-rw-r--r--test/lua/analyze.lua28
-rw-r--r--test/lua/capture.lua63
-rw-r--r--test/lua/combine9.lua107
-rw-r--r--test/lua/combine9view.lua125
-rw-r--r--test/lua/error.lua10
-rw-r--r--test/lua/fft.lua17
-rw-r--r--test/lua/flower.jpgbin17915 -> 0 bytes
-rw-r--r--test/lua/index.lua18
-rw-r--r--test/lua/info.lua149
-rw-r--r--test/lua/lena.jpgbin7145 -> 0 bytes
-rw-r--r--test/lua/multicrop.lua61
-rw-r--r--test/lua/multimorpho.lua103
-rw-r--r--test/lua/palette.lua6
-rw-r--r--test/lua/process.lua50
-rw-r--r--test/lua/process_new.lua44
-rw-r--r--test/lua/render.lua50
-rw-r--r--test/lua/render_cd.lua19
-rw-r--r--test/lua/screencapture.lua13
-rw-r--r--test/lua/show_flower.wlua31
-rw-r--r--test/lua/view.wlua183
-rw-r--r--test/lua/viewGL.wlua76
-rw-r--r--test/lua/view_image.lua76
22 files changed, 0 insertions, 1229 deletions
diff --git a/test/lua/analyze.lua b/test/lua/analyze.lua
deleted file mode 100644
index 7f06496..0000000
--- a/test/lua/analyze.lua
+++ /dev/null
@@ -1,28 +0,0 @@
-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")
diff --git a/test/lua/capture.lua b/test/lua/capture.lua
deleted file mode 100644
index 491518a..0000000
--- a/test/lua/capture.lua
+++ /dev/null
@@ -1,63 +0,0 @@
-require"imlua"
-require"imlua_capture"
-
-im.VideoCaptureReloadDevices()
-
-print("--- Devices ---")
-local n = im.VideoCaptureDeviceCount()
-
-for i = 0, n - 1 do
- desc = im.VideoCaptureDeviceDesc(i)
- print(desc)
-end
-
-local vc = im.VideoCaptureCreate()
-print("connect: ", vc:Connect(0))
-print()
-
-print("--- Dialogs ---")
-
-local dc = vc:DialogCount()
-for i = 0, dc - 1 do
- desc = vc:DialogDesc(i)
- print(i, desc)
- vc:ShowDialog(i)
-end
-print()
-
-
-print("--- Formats ---")
-
-local fc = vc:FormatCount()
-for i = 0, fc - 1 do
- local success, width, height, desc = vc:GetFormat(i)
- print(i, string.format("%dx%d", width, height), desc)
-end
-print()
-
-print("--- Image Size ---")
-local width, height = vc:GetImageSize()
-print(width, height)
-print()
-
-print("--- Attributes ---")
-attribs = vc:GetAttributeList()
-for i, name in ipairs(attribs) do
- local error, percent = vc:GetAttribute(name)
- if error == 0 then percent = "get error" end
- print(i, name, percent)
-end
---vc:SetAttribute("FlipVertical", 1)
---vc:SetAttribute("FlipHorizontal", 1)
-print()
-
-print("--- Capture ---")
-local image = im.ImageCreate(width, height, im.RGB, im.BYTE)
-local res = vc:Live(1)
-if (res > 0) then
- print("grabbing frame")
- print(vc:Frame(image, 3000))
-end
-image:Save("capture.jpg", "JPEG")
-
-vc:Disconnect()
diff --git a/test/lua/combine9.lua b/test/lua/combine9.lua
deleted file mode 100644
index 0bc1b17..0000000
--- a/test/lua/combine9.lua
+++ /dev/null
@@ -1,107 +0,0 @@
---A script to compose 9 photos, with 4/6 aspect ratio
-
-require"imlua"
-require"imlua_process"
-require"iuplua"
-
-function Confirm(title,msg)
- if continue then
- b=iup.Alarm(title, msg ,"Continue" ,"Exit")
- if b==2 then continue=false print("Script Aborted!") end
- end
-end
-
-function Create_Host_Image()
- if continue then
- local screenx=1024*3 screeny=684*3
- dst_photo = im.ImageCreate(screenx, screeny, im.RGB, im.BYTE)
- resize_photo = im.ImageCreate(1024, 684, im.RGB, im.BYTE) -- for resize
- end
-end
-
-function Create_Host_Name(name)
- if continue then
- i=0
- repeat
- i=i+1
- num=1000+i
- numstr=string.sub(tostring(num),-3)
--- path="D:/Composite/"
- path="D:/Downloads/Test/"
- ext=".jpg"
- Result=path..name..numstr..ext
- res,msg=io.open(Result)
- io.close()
- until not res
- end
-end
-
-function Get_Source_Photo()
- if continue then
--- path="D:/MyPictures/"
- path="D:/Downloads/Test/*.jpg"
- Source, err = iup.GetFile(path)
- print("Source: ", Source)
- if err<0 then continue=false end
- end
-end
-
-function Insert_Photo(num)
- if continue then
- title="Photo "..num.." of 9" msg=Source Confirm(title,msg)
- wd=dst_photo:Width()
- hd=dst_photo:Height()
- --print("Dst Size:",wd,hd)
- src_photo=im.FileImageLoadBitmap(Source)
- valuex=src_photo:Width()
- valuey=src_photo:Height()
- --print("Source Size:",valuex,valuey)
- panex={0,1024,2048,0,1024,2048,0,1024,2048}
- paney={0,0,0,684,684,684,1368,1368,1368}
- Xd=panex[num]
- Yd=paney[num]
- Wd=1024 Hd=684
- -- extract a proportional rectangle from the source image
- if 1.5*valuey>valuex then
- Ws=valuex
- Xs=0
- Hs=math.floor(valuex/1.5)
- Ys=math.floor((valuey-Hs)/2)
- else
- Hs=valuey
- Ys=0
- Ws=math.floor(1.5*Hs)
- Xs=math.floor((valuex-Ws)/2)
- end
-
- --print("Crop Size:",Ws, Hs)
- --print("Crop Shift:",Xs,Ys)
- crop_photo = im.ImageCreate(Ws, Hs, im.RGB, im.BYTE)
- im.ProcessCrop(src_photo, crop_photo, Xs,Ys)
- im.ProcessResize(crop_photo, resize_photo, 1) -- do bilinear interpolation
- im.ProcessInsert(dst_photo, resize_photo, dst_photo, Xd, Yd) -- insert resize in dst and place the result in dst
- crop_photo:Destroy()
-
- if num==9 then src_photo:CopyAttributes(dst_photo) end
- end
-end
-
-function Save_Composite_Photo()
- if continue then
- name="Composite"
- Create_Host_Name(name)
- dst_photo:Save(Result, "JPEG")
- os.execute(Result)
- end
-end
-
---Script Starts
-continue=true
-title="9 Panel Composite" msg="Photos can be anysize." Confirm(title,msg)
-Create_Host_Image()
-for i=1,9 do
- num=i
- Get_Source_Photo()
- Insert_Photo(num)
- end
-Save_Composite_Photo()
diff --git a/test/lua/combine9view.lua b/test/lua/combine9view.lua
deleted file mode 100644
index d606355..0000000
--- a/test/lua/combine9view.lua
+++ /dev/null
@@ -1,125 +0,0 @@
---A script to compose 9 photos, with 4/6 aspect ratio
-
-require"imlua"
-require"imlua_process"
-require"iuplua"
-require"view_image"
-
-err_msg = {
- "No error.",
- "Error while opening the file.",
- "Error while accessing the file.",
- "Invalid or unrecognized file format.",
- "Invalid or unsupported data.",
- "Invalid or unsupported compression.",
- "Insufficient memory",
- "Interrupted by the counter",
-}
-
-function Confirm(title,msg)
- if continue then
- b=iup.Alarm(title, msg ,"Continue" ,"Exit")
- if b==2 then continue=false print("Script Aborted!") end
- end
-end
-
-function Create_Host_Image()
- if continue then
- local screenx=1024*3 screeny=684*3
- dst_photo = im.ImageCreate(screenx, screeny, im.RGB, im.BYTE)
- resize_photo = im.ImageCreate(1024, 684, im.RGB, im.BYTE) -- for resize
- end
-end
-
-function Create_Host_Name(name)
- if continue then
- i=0
- repeat
- i=i+1
- num=1000+i
- numstr=string.sub(tostring(num),-3)
--- path="D:/Composite/"
--- path="D:/Downloads/Test/"
- path = "./"
- ext=".jpg"
- Result=path..name..numstr..ext
- res,msg=io.open(Result)
- io.close()
- until not res
- end
-end
-
-function Get_Source_Photo()
- if continue then
--- path="D:/MyPictures/"
- path="test/*.jpg"
- Source, err = iup.GetFile(path)
- print("Source: ", Source)
- if err<0 then continue=false end
- end
-end
-
-function Insert_Photo(num)
- if continue then
- title="Photo "..num.." of 9" --msg=Source Confirm(title,msg)
- wd=dst_photo:Width()
- hd=dst_photo:Height()
- --print("Dst Size:",wd,hd)
- src_photo, err=im.FileImageLoadBitmap(Source)
- if (err and err ~= im.ERR_NONE) then
- error(err_msg[err+1])
- end
- if (not View_Image(src_photo, title)) then continue = false return end
- valuex=src_photo:Width()
- valuey=src_photo:Height()
- --print("Source Size:",valuex,valuey)
- panex={0,1024,2048,0,1024,2048,0,1024,2048}
- paney={0,0,0,684,684,684,1368,1368,1368}
- Xd=panex[num]
- Yd=paney[num]
- Wd=1024 Hd=684
- -- extract a proportional rectangle from the source image
- if 1.5*valuey>valuex then
- Ws=valuex
- Xs=0
- Hs=math.floor(valuex/1.5)
- Ys=math.floor((valuey-Hs)/2)
- else
- Hs=valuey
- Ys=0
- Ws=math.floor(1.5*Hs)
- Xs=math.floor((valuex-Ws)/2)
- end
-
- --print("Crop Size:",Ws, Hs)
- --print("Crop Shift:",Xs,Ys)
- crop_photo = im.ImageCreate(Ws, Hs, im.RGB, im.BYTE)
- im.ProcessCrop(src_photo, crop_photo, Xs,Ys)
- im.ProcessResize(crop_photo, resize_photo, 1) -- do bilinear interpolation
- im.ProcessInsert(dst_photo, resize_photo, dst_photo, Xd, Yd) -- insert resize in dst and place the result in dst
- crop_photo:Destroy()
-
- if num==9 then src_photo:CopyAttributes(dst_photo) end
- end
-end
-
-function Save_Composite_Photo()
- if continue then
- name="Composite"
- Create_Host_Name(name)
- if (not View_Image(dst_photo, "Composite")) then continue = false return end
- dst_photo:Save(Result, "JPEG")
- --os.execute(Result)
- end
-end
-
---Script Starts
-continue=true
-title="9 Panel Composite" msg="Photos can be anysize." Confirm(title,msg)
-Create_Host_Image()
-for i=1,9 do
- num=i
- Get_Source_Photo()
- Insert_Photo(num)
- end
-Save_Composite_Photo()
diff --git a/test/lua/error.lua b/test/lua/error.lua
deleted file mode 100644
index f8c71a8..0000000
--- a/test/lua/error.lua
+++ /dev/null
@@ -1,10 +0,0 @@
-require"imlua"
-
-local filename = "lena.jpg"
-local image = im.FileImageLoad(filename)
-local image2 = im.ImageCreate(image:Width(), image:Height(), im.GRAY, im.USHORT)
-
--- Both calls will signal an error because of incompatible parameters
-
---im.ConvertDataType(image, image2, im.CPX_REAL, im.GAMMA_LINEAR, 0, im.CAST_MINMAX)
-im.ConvertColorSpace(image, image2, im.CPX_REAL, im.GAMMA_LINEAR, 0, im.CAST_MINMAX)
diff --git a/test/lua/fft.lua b/test/lua/fft.lua
deleted file mode 100644
index 3589635..0000000
--- a/test/lua/fft.lua
+++ /dev/null
@@ -1,17 +0,0 @@
-require"imlua"
-require"imlua_process"
-require"imlua_fftw"
-
-local filename = "lena.jpg"
-local image = im.FileImageLoad(filename)
-
-local complex = im.ImageCreate(image:Width(), image:Height(), image:ColorSpace(), im.CFLOAT)
-im.ProcessFFT(image, complex)
-
-local c = complex[0][5][10] -- component=0(Red), y = 5 x =10
-print(c[1], c[2])
-
-complex[0][5][10] = { 2*c[1], c[2]/2 }
-
-local c = complex[0][5][10]
-print(c[1], c[2])
diff --git a/test/lua/flower.jpg b/test/lua/flower.jpg
deleted file mode 100644
index 2b9dbf1..0000000
--- a/test/lua/flower.jpg
+++ /dev/null
Binary files differ
diff --git a/test/lua/index.lua b/test/lua/index.lua
deleted file mode 100644
index 1c4c1e4..0000000
--- a/test/lua/index.lua
+++ /dev/null
@@ -1,18 +0,0 @@
-require"imlua"
-
-local filename = "lena.jpg"
-local image = im.FileImageLoad(filename)
-
-local r = image[0]
-local g = image[1]
-local b = image[2]
-
-for row = 0, image:Height() - 1, 10 do
- for column = 0, image:Width() - 1, 10 do
- r[row][column] = 0
- g[row][column] = 0
- b[row][column] = 0
- end
-end
-
-image:Save("lena_indexing.bmp", "BMP")
diff --git a/test/lua/info.lua b/test/lua/info.lua
deleted file mode 100644
index b1afb2a..0000000
--- a/test/lua/info.lua
+++ /dev/null
@@ -1,149 +0,0 @@
-require"imlua"
-require"lfs"
-
-function PrintError(error)
- local msg = {}
- msg[im.ERR_OPEN] = "Error Opening File."
- msg[im.ERR_MEM] = "Insuficient memory."
- msg[im.ERR_ACCESS] = "Error Accessing File."
- msg[im.ERR_DATA] = "Image type not Suported."
- msg[im.ERR_FORMAT] = "Invalid Format."
- msg[im.ERR_COMPRESS] = "Invalid or unsupported compression."
-
- if msg[error] then
- print(msg[error])
- else
- print("Unknown Error.")
- end
-end
-
-function FindZero(data)
- if (not data) then return false end
- for i = 1, table.getn(data) do
- if data[i] == 0 then
- return true
- end
- end
- return false
-end
-
-function AttribData2Str(data, data_type)
- local data_str
-
- if data_type == im.BYTE then
- data_str = string.format("%3d", data[1])
- elseif data_type == im.USHORT then
- data_str = string.format("%5d", data[1])
- elseif data_type == im.INT then
- data_str = string.format("%5d", data[1])
- elseif data_type == im.FLOAT then
- data_str = string.format("%5.2f", data[1])
- elseif data_type == im.CFLOAT then
- data_str = string.format("%5.2f, %5.2f", data[1], data[2])
- end
-
- return data_str
-end
-
-function GetSizeDesc(size)
- local size_desc
-
- if size < 1024 then
- size_desc = "b"
- else
- size = size / 1024
-
- if size < 1024 then
- size_desc = "Kb"
- else
- size = size / 1024
- size_desc = "Mb"
- end
- end
-
- return size, size_desc
-end
-
-function FileSize(file_name)
- if lfs then
- local attr = lfs.attributes(file_name)
- return attr.size
- else
- return 0
- end
-end
-
-function PrintImageInfo(file_name)
- print("IM Info")
- print(string.format(" File Name:\n %s", file_name))
-
- local ifile, error = im.FileOpen(file_name)
- if not ifile then
- PrintError(error)
- return nil
- end
-
- local file_size = FileSize(file_name)
-
- print(string.format(" File Size: %.2f %s", GetSizeDesc(file_size)))
-
- local format, compression, image_count = ifile:GetInfo()
-
- local error, format_desc = im.FormatInfo(format)
- print(string.format(" Format: %s - %s", format, format_desc))
- print(string.format(" Compression: %s", compression))
- print(string.format(" Image Count: %d", image_count))
- for i = 1, image_count do
- local error, width, height, color_mode, data_type = ifile:ReadImageInfo(i-1)
- if width == nil then
- PrintError(height)
- ifile:Close()
- return nil
- end
-
- print(string.format(" Image #%d", i))
- print(string.format(" Width: %d", width))
- print(string.format(" Height: %d", height))
- print(string.format(" Color Space: %s", im.ColorModeSpaceName(color_mode)))
- print(string.format(" Has Alpha: %s", im.ColorModeHasAlpha(color_mode) and "Yes" or "No"))
- print(string.format(" Is Packed: %s", im.ColorModeIsPacked(color_mode) and "Yes" or "No"))
- print(string.format(" Is Top Down: %s", im.ColorModeIsTopDown(color_mode) and "Yes" or "No"))
- print(string.format(" Data Type: %s", im.DataTypeName(data_type)))
-
- local image_size = im.ImageDataSize(width, height, color_mode, data_type)
- print(string.format(" Data Size: %.2f %s", GetSizeDesc(image_size)))
-
- local attrib_list = ifile:GetAttributeList()
- for a = 1, table.getn(attrib_list) do
- if a == 1 then
- print(" Attributes:")
- end
-
- local attrib_data, attrib_data_type = ifile:GetAttribute(attrib_list[a])
-
- if table.getn(attrib_data) == 1 then
- print(string.format(" %s: %s", attrib_list[a], AttribData2Str(attrib_data, attrib_data_type)))
- elseif attrib_data_type == im.BYTE and FindZero(attrib_data) then
- attrib_data = ifile:GetAttribute(attrib_list[a], true)
- print(string.format(" %s: %s", attrib_list[a], attrib_data))
- else
- print(string.format(" %s: %s ...", attrib_list[a], AttribData2Str(attrib_data, attrib_data_type)))
- end
- end
- end
-
- ifile:Close()
-end
-
-function main(arg)
- if (not arg or table.getn(arg) < 1) then
- print("Invalid number of arguments.")
- return nil
- end
-
- PrintImageInfo(arg[1])
- return 1
-end
-
-main(arg)
---PrintImageInfo("lena.jpg")
diff --git a/test/lua/lena.jpg b/test/lua/lena.jpg
deleted file mode 100644
index b6bad61..0000000
--- a/test/lua/lena.jpg
+++ /dev/null
Binary files differ
diff --git a/test/lua/multicrop.lua b/test/lua/multicrop.lua
deleted file mode 100644
index 6af3e52..0000000
--- a/test/lua/multicrop.lua
+++ /dev/null
@@ -1,61 +0,0 @@
--- lua5.1 multicrop.lua 100 500 100 500 *.jpg
-
-require"imlua"
-require"imlua_process"
-
-err_msg = {
- "No error.",
- "Error while opening the file.",
- "Error while accessing the file.",
- "Invalid or unrecognized file format.",
- "Invalid or unsupported data.",
- "Invalid or unsupported compression.",
- "Insuficient memory",
- "Interrupted by the counter",
-}
-
-x1 = arg[1]
-x2 = arg[2]
-y1 = arg[3]
-y2 = arg[4]
-filename1 = arg[5]
-if (not x1 or not x2 or not y1 or not y2 or not filename1) then
- print("Must have the rectangle coordinates and at least one file name as parameters.")
- print(" Can have more than one file name as parameters and can use wildcards.")
- print(" Usage:")
- print(" lua multicrop.lua x1 x2 y1 y2 filename1 filename2 ...")
- return
-end
-
-print(">>> Crop of multiple images <<<")
-print("")
-
-function ProcessImageFile(file_name)
- print("Loading File: "..file_name)
- image, err = im.FileImageLoad(file_name);
-
- if (err and err ~= im.ERR_NONE) then
- error(err_msg[err+1])
- end
-
- new_image = im.ProcessCropNew(image, x1, x2, y1, y2)
-
- new_image:Save(file_name, "JPEG");
-
- new_image:Destroy()
- image:Destroy()
- print("Done File.")
- print("")
-end
-
-file_count = 0
-for index,value in ipairs(arg) do
- if (index > 4) then
- ProcessImageFile(arg[index])
- file_count = file_count + 1
- end
-end
-
-if (file_count > 1) then
- print("Processed "..file_count.." Files.")
-end
diff --git a/test/lua/multimorpho.lua b/test/lua/multimorpho.lua
deleted file mode 100644
index 742d713..0000000
--- a/test/lua/multimorpho.lua
+++ /dev/null
@@ -1,103 +0,0 @@
--- multi-step morphological opening on a binarized image, with increasing structuring element (Se) size:
--- step 1 - 3x3 Se
--- step 2 - 5x5 Se
--- step 3 - 7x7 Se
--- Step n - (2n+1)x (2n+1) Se
--- after each step, a count of the objects (white items) in the opened image has to be performed,
--- and the number of counted items to be saved in a .txt file for easy and fast exporting to excel
-
-require"imlua"
-require"imlua_process"
-
-err_msg = {
- "No error.",
- "Error while opening the file.",
- "Error while accessing the file.",
- "Invalid or unrecognized file format.",
- "Invalid or unsupported data.",
- "Invalid or unsupported compression.",
- "Insufficient memory",
- "Interrupted by the counter",
-}
-
-colorspace_str = {
- "RGB",
- "MAP",
- "GRAY",
- "BINARY",
- "CMYK",
- "YCBCR",
- "LAB",
- "LUV",
- "XYZ"
-}
-
-num_step = arg[1]
-file_name1 = arg[2]
-if (not num_step or not file_name1) then
- print("Must have the number of steps and a file name as parameters.")
- print(" Can have more than one file name as parameters and can use wildcards.")
- print(" Usage:")
- print(" lua multimorpho.lua num_step filename1 filename2 ...")
- return
-end
-
-print(">>> Multi-step Morphological Opening <<<")
-print("Number of Steps: "..num_step)
-print("")
-
-function ProcessImageFile(file_name, num_step)
- print("Loading File: "..file_name)
- image, err = im.FileImageLoad(file_name);
-
- if (err and err ~= im.ERR_NONE) then
- error(err_msg[err+1])
- end
-
- if (image:ColorSpace() ~= im.BINARY) then
- error("Invalid Image Color Space. Must be a Binary image [Color Space="..colorspace_str[image:ColorSpace()+1].."].")
- end
-
- file_name = file_name..".csv"
- print("Saving Log File: "..file_name)
- log = io.open(file_name, "w")
-
- morph_image = image:Clone()
- obj_image = im.ImageCreateBased(image, nil, nil, im.GRAY, im.USHORT)
-
- for step = 1, num_step do
- kernel_size = 2*step+1
- print(" Binary Morphology Open [Kernel Size="..kernel_size.."x"..kernel_size.."].")
- im.ProcessBinMorphOpen(image, morph_image, kernel_size, 1) -- 1 interaction
-
- num_obj = im.AnalyzeFindRegions(morph_image, obj_image, 4, false) -- 4 connected, ignore objects that touch the border
- print(" Objects Found: "..num_obj)
- log:write(kernel_size..";"..num_obj.."\n")
-
- if (num_obj == 0) then
- step = num_step
- end
-
- obj_image:Clear()
- morph_image:Clear()
- end
-
- log:close()
- obj_image:Destroy()
- morph_image:Destroy()
- image:Destroy()
- print("Done File.")
- print("")
-end
-
-file_count = 0
-for index,value in ipairs(arg) do
- if (index > 1) then
- ProcessImageFile(arg[index], num_step)
- file_count = file_count + 1
- end
-end
-
-if (file_count > 1) then
- print("Processed "..file_count.." Files.")
-end
diff --git a/test/lua/palette.lua b/test/lua/palette.lua
deleted file mode 100644
index 5ec7168..0000000
--- a/test/lua/palette.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-require"imlua"
-
-local impal = im.PaletteHotIron()
-print(impal)
-print(im.ColorDecode(impal[1]))
-
diff --git a/test/lua/process.lua b/test/lua/process.lua
deleted file mode 100644
index e942b27..0000000
--- a/test/lua/process.lua
+++ /dev/null
@@ -1,50 +0,0 @@
-require"imlua"
-require"imlua_process"
-
-function save_histogram (hist, filename, format)
- local height = 200 -- altura da imagem
- local max = math.max(unpack(hist)) -- pega o maior valor do histograma
- local n = table.getn(hist) + 1 -- zero-based
- local image = im.ImageCreate(n, height, im.GRAY, im.BYTE) -- cria a imagem
- local white = 255
- local black = 0
-
- local render = function (x, y, d, param)
- local v = hist[x] / max
- local h = v * height
- if y <= h then return black end
- return white
- end
-
- im.ProcessRenderOp(image, render, "histogram", {}, 0)
- image:Save(filename, format)
-end
-
-local filename = "lena.jpg"
-
-local image = im.FileImageLoad(filename)
-
-save_histogram(im.CalcHistogram(image, 0, 0), "lena_histogram_R.gif", "GIF")
-save_histogram(im.CalcHistogram(image, 1, 0), "lena_histogram_G.gif", "GIF")
-save_histogram(im.CalcHistogram(image, 2, 0), "lena_histogram_B.gif", "GIF")
-save_histogram(im.CalcGrayHistogram(image, 0), "lena_histogram_gray.gif", "GIF")
-
-local r = im.ImageCreate(image:Width(), image:Height(), im.GRAY, image:DataType())
-local g = im.ImageCreate(image:Width(), image:Height(), im.GRAY, image:DataType())
-local b = im.ImageCreate(image:Width(), image:Height(), im.GRAY, image:DataType())
-im.ProcessSplitComponents(image, { r, g, b})
-r:Save("lena_r.jpg", "JPEG")
-g:Save("lena_g.jpg", "JPEG")
-b:Save("lena_b.jpg", "JPEG")
-
-local rgb = image:Clone()
-im.ProcessMergeComponents({r, g, b}, rgb)
-rgb:Save("lena_rgb.jpg", "JPEG")
-
-local replace = image:Duplicate()
-im.ProcessReplaceColor(image, replace, { 146, 93, 145 }, { 255, 0, 255 })
-replace:Save("lena_replace.jpg", "JPEG")
-
-local bitmask = image:Duplicate()
-im.ProcessBitMask(image, bitmask, "01111010", im.BIT_XOR)
-bitmask:Save("lena_bitmask.jpg", "JPEG")
diff --git a/test/lua/process_new.lua b/test/lua/process_new.lua
deleted file mode 100644
index 93ebcce..0000000
--- a/test/lua/process_new.lua
+++ /dev/null
@@ -1,44 +0,0 @@
-require"imlua"
-require"imlua_process"
-
-function save_histogram (hist, filename, format)
- local height = 200 -- altura da imagem
- local max = math.max(unpack(hist)) -- pega o maior valor do histograma
- local n = table.getn(hist) + 1 -- zero-based
- local image = im.ImageCreate(n, height, im.GRAY, im.BYTE) -- cria a imagem
- local white = 255
- local black = 0
-
- local render = function (x, y, d, param)
- local v = hist[x] / max
- local h = v * height
- if y <= h then return black end
- return white
- end
-
- im.ProcessRenderOp(image, render, "histogram", {}, 0)
- image:Save(filename, format)
-end
-
-local filename = "lena.jpg"
-
-local image = im.FileImageLoad(filename)
-
-save_histogram(im.CalcHistogram(image, 0, 0), "lena_histogram_R.gif", "GIF")
-save_histogram(im.CalcHistogram(image, 1, 0), "lena_histogram_G.gif", "GIF")
-save_histogram(im.CalcHistogram(image, 2, 0), "lena_histogram_B.gif", "GIF")
-save_histogram(im.CalcGrayHistogram(image, 0), "lena_histogram_gray.gif", "GIF")
-
-local r, g, b = im.ProcessSplitComponentsNew(image)
-r:Save("lena_r.jpg", "JPEG")
-g:Save("lena_g.jpg", "JPEG")
-b:Save("lena_b.jpg", "JPEG")
-
-local rgb = im.ProcessMergeComponentsNew({r, g, b})
-rgb:Save("lena_rgb.jpg", "JPEG")
-
-local replace = im.ProcessReplaceColorNew(image, { 146, 93, 145 }, { 255, 0, 255 })
-replace:Save("lena_replace.jpg", "JPEG")
-
-local bitmask = im.ProcessBitMaskNew(image, "01111010", im.BIT_XOR)
-replace:Save("lena_bitmask.jpg", "JPEG")
diff --git a/test/lua/render.lua b/test/lua/render.lua
deleted file mode 100644
index b57f906..0000000
--- a/test/lua/render.lua
+++ /dev/null
@@ -1,50 +0,0 @@
-require"imlua"
-require"imlua_process"
-
-local image = im.ImageCreate(500, 500, im.RGB, im.BYTE)
-
-im.ProcessRenderRandomNoise(image)
-image:Save("render_noise.bmp", "BMP")
-
-im.ProcessRenderConstant(image, { 128.0, 0.0, 255.0 })
-image:Save("render_constant.bmp", "BMP")
-
-im.ProcessRenderWheel(image, 100, 200)
-image:Save("render_wheel.bmp", "BMP")
-
-im.ProcessRenderTent(image, 300, 200)
-image:Save("render_tent.bmp", "BMP")
-
-im.ProcessRenderRamp(image, 0, 500, 0)
-image:Save("render_ramp.bmp", "BMP")
-
-im.ProcessRenderBox(image, 200, 200)
-image:Save("render_box.bmp", "BMP")
-
-im.ProcessRenderSinc(image, 100.0, 100.0)
-image:Save("render_sinc.bmp", "BMP")
-
-im.ProcessRenderGaussian(image, 100.0)
-image:Save("render_gaussian.bmp", "BMP")
-
-im.ProcessRenderLapOfGaussian(image, 100.0)
-image:Save("render_lapofgaussian.bmp", "BMP")
-
-im.ProcessRenderCosine(image, 100.0, 100.0)
-image:Save("render_cosine.bmp", "BMP")
-
-im.ProcessRenderGrid(image, 100.0, 100.0)
-image:Save("render_grid.bmp", "BMP")
-
-im.ProcessRenderChessboard(image, 100.0, 100.0)
-image:Save("render_chess.bmp", "BMP")
-
-im.ProcessRenderCone(image, 200)
-image:Save("render_cone.bmp", "BMP")
-
-local render_func = function (x, y, d, param)
- return math.mod(x + y, 256)
-end
-
-im.ProcessRenderOp(image, render_func, "test", {}, 0)
-image:Save("render_func.bmp", "BMP")
diff --git a/test/lua/render_cd.lua b/test/lua/render_cd.lua
deleted file mode 100644
index 4af8a16..0000000
--- a/test/lua/render_cd.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-require"imlua"
-require"cdlua"
-require"cdluaim"
-
-local image = im.ImageCreate(500, 500, im.RGB, im.BYTE)
-local canvas = image:cdCreateCanvas() -- Creates a CD_IMAGERGB canvas
-
-canvas:Activate()
-canvas:Background(cd.EncodeColor(255, 255, 255))
-canvas:Clear()
-fgcolor = cd.EncodeColor(255, 0, 0) -- red
-fgcolor = cd.EncodeAlpha(fgcolor, 50) -- semi transparent
-canvas:Foreground(fgcolor)
-canvas:Font("Times", cd.BOLD, 24)
-canvas:Text(100, 100, "Test")
-canvas:Line(0,0,100,100)
-canvas:Kill()
-
-image:Save("new.bmp", "BMP")
diff --git a/test/lua/screencapture.lua b/test/lua/screencapture.lua
deleted file mode 100644
index 16eb94e..0000000
--- a/test/lua/screencapture.lua
+++ /dev/null
@@ -1,13 +0,0 @@
-require"imlua"
-require"cdlua"
-require"cdluaim"
-
-local canvas = cd.CreateCanvas(cd.NATIVEWINDOW, nil)
-canvas:Activate()
-local w, h = canvas:GetSize()
-local image = im.ImageCreate(w, h, im.RGB, im.BYTE)
-image:cdCanvasGetImage(canvas, 0, 0)
-error = image:Save("screencapture.jpg", "JPEG")
-image:Destroy()
-if (error) then print("error = "..error) end
-
diff --git a/test/lua/show_flower.wlua b/test/lua/show_flower.wlua
deleted file mode 100644
index ec97a88..0000000
--- a/test/lua/show_flower.wlua
+++ /dev/null
@@ -1,31 +0,0 @@
-require"imlua"
-require"cdlua"
-require"cdluaim"
-require"iuplua"
-require"iupluacd"
-
-image = im.FileImageLoad("flower.jpg") -- directly load the image at index 0. it will open and close the file
-cnv = iup.canvas{rastersize = image:Width().."x"..image:Height(), border = "NO"}
-cnv.image = image -- store the new image in the IUP canvas as an attribute
-
-function cnv:map_cb() -- the CD canvas can only be created when the IUP canvas is mapped
- self.canvas = cd.CreateCanvas(cd.IUP, self)
-end
-
-function cnv:action() -- called everytime the IUP canvas needs to be repainted
- self.canvas:Activate()
- self.canvas:Clear()
- self.image:cdCanvasPutImageRect(self.canvas, 0, 0, 0, 0, 0, 0, 0, 0) -- use default values
-end
-
-dlg = iup.dialog{cnv}
-
-function dlg:close_cb()
- cnv.image:Destroy()
- cnv.canvas:Kill()
- self:destroy()
- return iup.IGNORE -- because we destroy the dialog
-end
-
-dlg:show()
-iup.MainLoop()
diff --git a/test/lua/view.wlua b/test/lua/view.wlua
deleted file mode 100644
index 60be33e..0000000
--- a/test/lua/view.wlua
+++ /dev/null
@@ -1,183 +0,0 @@
-require"imlua"
-require"cdlua"
-require"cdluaim"
-require"iuplua"
-require"iupluacd"
-
-function PrintError(func, error)
- local msg = {}
- msg[im.ERR_OPEN] = "Error Opening File."
- msg[im.ERR_MEM] = "Insuficient memory."
- msg[im.ERR_ACCESS] = "Error Accessing File."
- msg[im.ERR_DATA] = "Image type not Suported."
- msg[im.ERR_FORMAT] = "Invalid Format."
- msg[im.ERR_COMPRESS] = "Invalid or unsupported compression."
-
- if msg[error] then
- print(func..": "..msg[error])
- else
- print("Unknown Error.")
- end
-end
-
-function LoadImage(file_name)
- local image
- local ifile, error = im.FileOpen(file_name)
- if not ifile then
- PrintError("open", error)
- return
- end
-
- -- load the first image in the file.
- -- force the image to be converted to a bitmap
- image, error = ifile:LoadBitmap()
- if not image then
- PrintError("load", error)
- return
- end
-
- ifile:Close()
- return image
-end
-
-
-dlg = nil -- only one dlg
-
-function ShowImage(file_name)
-
- local image = LoadImage(file_name)
- if not image then
- return false
- end
-
- if dlg then
- local old_canvas = dlg.canvas
- local old_image = dlg.image
-
- if old_canvas ~= nil then old_canvas:Kill() end
- if old_image ~= nil then old_image:Destroy() end
-
- iup.Destroy(dlg)
- end
-
- cnv = iup.canvas{}
-
- function cnv:action()
- local canvas = dlg.canvas
- local image = dlg.image
-
- if (not canvas) then return end
-
- -- posy is top-down, CD is bottom-top.
- -- invert scroll reference (YMAX-DY - POSY).
- y = self.ymax-self.dy - self.posy
- if (y < 0) then y = 0 end
-
-
- canvas:Activate()
- canvas:Clear()
- x = -self.posx
- y = -y
- image:cdCanvasPutImageRect(canvas, x, y, image:Width(), image:Height(), 0, 0, 0, 0)
- canvas:Flush()
-
- return iup.DEFAULT
- end
-
- function cnv:button_cb()
- local file_name = "*.*"
- local error
-
- file_name, error = iup.GetFile(file_name)
- if error ~= 0 then
- return iup.DEFAULT
- end
-
- ShowImage(file_name)
- return iup.DEFAULT
- end
-
-
- -- Set the Canvas inicial size (IUP will retain this value).
- w = image:Width()
- h = image:Height()
- if (w > 800) then w = 800 end
- if (h > 600) then h = 600 end
- cnv.rastersize = string.format("%dx%d", w, h)
- cnv.border = "no"
- cnv.scrollbar = "yes"
- cnv.xmax = image:Width()-1
- cnv.ymax = image:Height()-1
-
- function cnv:resize_cb(w, h)
- self.dx = w
- self.dy = h
- self.posx = self.posx -- needed only in IUP 2.x
- self.posy = self.posy
- end
-
- dlg = iup.dialog{cnv}
- dlg.title = file_name
- dlg.cnv = cnv
- dlg.image = image
-
- function dlg:close_cb()
- local canvas = self.canvas
- local image = self.image
-
- if canvas then canvas:Kill() end
- if image then image:Destroy() end
-
- return iup.CLOSE
- end
-
- function dlg:map_cb()
- canvas = cd.CreateCanvas(cd.IUP, self.cnv)
- self.canvas = canvas
- self.posx = 0 -- needed only in IUP 2.x
- self.posy = 0
- end
-
- dlg:show()
- cnv.rastersize = nil -- to remove the minimum limit
-
- return true
-end
-
-function main(arg)
- local file_name = "*.*"
- local error
-
- -- Try to get a file name from the command line.
- if (arg == nil or table.getn(arg) < 2) then
- file_name, error = iup.GetFile(file_name)
- if error ~= 0 then
- return true
- end
- else
- file_name = arg[1]
- end
-
- if not ShowImage(file_name) then
- local Try = true
- -- If ShowImage returns an error I will try to read another image.
- -- I can give up on File Open dlg choosing "Cancel".
- while Try do
- file_name = "*.*"
-
- file_name, error = iup.GetFile(file_name)
- if error ~= 0 then
- return true
- end
-
- if ShowImage(file_name) then
- Try = false
- end
- end
- end
-
- iup.MainLoop()
- return true
-end
-
-main(arg)
diff --git a/test/lua/viewGL.wlua b/test/lua/viewGL.wlua
deleted file mode 100644
index f5ce58a..0000000
--- a/test/lua/viewGL.wlua
+++ /dev/null
@@ -1,76 +0,0 @@
-require("iuplua")
-require("iupluagl")
-require("luagl")
-require("imlua")
-
-iup.key_open()
-
-texture = 0
-
-cnv = iup.glcanvas{buffer="DOUBLE", rastersize = "640x480"}
-
-function cnv:resize_cb(width, height)
- iup.GLMakeCurrent(self)
- gl.Viewport(0, 0, width, height)
-end
-
-function cnv:action(x, y)
- iup.GLMakeCurrent(self)
- gl.PixelStore(gl.UNPACK_ALIGNMENT, 1)
- gl.Clear('COLOR_BUFFER_BIT,DEPTH_BUFFER_BIT') -- Clear Screen And Depth Buffer
-
- gl.DrawPixelsRaw (image:Width(), image:Height(), glformat, gl.UNSIGNED_BYTE, gldata)
-
- iup.GLSwapBuffers(self)
-end
-
-function cnv:k_any(c)
- if c == iup.K_q or c == iup.K_ESC then
- return iup.CLOSE
- end
-
- if c == iup.K_F1 then
- if fullscreen then
- fullscreen = false
- dlg.fullscreen = "No"
- else
- fullscreen = true
- dlg.fullscreen = "Yes"
- end
- end
-
- if c == iup.K_F2 then
- fileName = iup.GetFile("*.*")
- new_image = im.FileImageLoadBitmap(fileName)
- if (not new_image) then
- iup.Message("Error", "LoadBitmap failed.")
- else
- gldata, glformat = new_image:GetOpenGLData()
- if (image) then image:Destroy() end
- image = new_image
- iup.Update(cnv)
- end
- end
-
-end
-
-if arg and arg[1] ~= nil then
- fileName = arg[1]
-else
- fileName = iup.GetFile("*.*")
-end
-
-image = im.FileImageLoadBitmap(fileName)
-if (not image) then
- error("LoadBitmap failed.")
-end
-gldata, glformat = image:GetOpenGLData()
-
-dlg = iup.dialog{cnv; title="LuaGL/IUP/IM Loader"}
-
-dlg:show()
-cnv.rastersize = nil -- reset minimum limitation
-
-if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then
- iup.MainLoop()
-end
diff --git a/test/lua/view_image.lua b/test/lua/view_image.lua
deleted file mode 100644
index c156bd3..0000000
--- a/test/lua/view_image.lua
+++ /dev/null
@@ -1,76 +0,0 @@
-require"imlua"
-require"cdlua"
-require"cdluaim"
-require"iuplua"
-require"iupluacd"
-
-iup.key_open()
-
-function View_Image(image, title)
- ret = false
-
- cnv = iup.canvas{}
-
- function cnv:action()
- local canvas = dlg.canvas
- local image = dlg.image
-
- if (not canvas) then return end
-
- canvas:Activate()
- cw, ch = canvas:GetSize()
- iw = image:Width()
- ih = image:Height()
-
- if (iw > ih) then
- h = iw/iw * ch
- y = (ch-h)/2
- x = 0
- w = cw
- else
- w = iw/ih * ch
- x = (cw-w)/2
- y = 0
- h = ch
- end
-
- canvas:Clear()
- image:cdCanvasPutImageRect(canvas, x, y, w, h, 0, 0, 0, 0)
- end
-
- function cnv:button_cb()
- dlg:close_cb()
- ret = true
- return iup.CLOSE
- end
-
- dlg = iup.dialog{iup.vbox{cnv, iup.label{title="Click to accept or press Esc to abort."}}}
- dlg.placement="maximized"
- dlg.title = title
- dlg.cnv = cnv
- dlg.image = image
-
- function dlg:k_any(c)
- print("K_any("..c..")")
- if (c == iup.K_ESC) then
- dlg:close_cb()
- return iup.CLOSE
- end
- end
-
- function dlg:close_cb()
- local canvas = self.canvas
- if canvas then canvas:Kill() end
- end
-
- function dlg:map_cb()
- canvas = cd.CreateCanvas(cd.IUP, self.cnv)
- self.canvas = canvas
- end
-
- dlg:show()
- iup.MainLoop()
- dlg:destroy()
-
- return ret
-end