automatic commit - 25-11-2022
This commit is contained in:
42
tools/vision/scripts/clip_loop.vcs
Normal file
42
tools/vision/scripts/clip_loop.vcs
Normal file
@@ -0,0 +1,42 @@
|
||||
; LDV script sample
|
||||
; Demonstrates automate image operations from a folder
|
||||
; This script take each image from a folder, extract a block
|
||||
; And saves that block as an image file
|
||||
|
||||
; Inside the loop:
|
||||
; current file is accessible via $LFCurrentFile global variable
|
||||
; start folder (parameter#1 of Loop_Folder) is accessible via $LFStartFolder global variable
|
||||
; Global function LFAdjustDest(<start_folder,file,dest_folder>) allows to build destination file
|
||||
; In such a way that it respects original folder hierachy, e.g.:
|
||||
; Assuming LFStartFolder=H:\IMAGES
|
||||
; And $LFCurrentFile=H:\IMAGES\BYPLANES\32\TC32.JPG
|
||||
; Then LFAdjustDest($LFStartFolder,$LFCurrentFile,H:\OPTIMAL) will be H:\OPTIMAL\BYPLANES\32
|
||||
|
||||
; Starts the loop on a folder (not recursing)
|
||||
Loop_Folder H:\PURE_C\PROJECTS\VISION\IMGTEST
|
||||
|
||||
; Open current image file
|
||||
open $LFCurrentFile
|
||||
|
||||
; Select a block on this picture
|
||||
clip_sel $LFCurrentFile 16 16 256 192
|
||||
|
||||
; Copy that block into clipboard
|
||||
clip_copy
|
||||
|
||||
; Paste clipboard to new page using same filename
|
||||
clip_pasten LFAdjustDest($LFStartFolder,$LFCurrentFile,H:\PURE_C\PROJECTS\VISION\IMGTEST\TEMP)
|
||||
|
||||
; We don't need loaded picture anymore
|
||||
close $LFCurrentFile
|
||||
|
||||
; Save new image to disk (same window name and filename)
|
||||
; Note quality=90;compression=lzw
|
||||
; This is to force JPEG quality to 90 and compression to LZW (TIFF)
|
||||
save LFAdjustDest($LFStartFolder,$LFCurrentFile,H:\PURE_C\PROJECTS\VISION\IMGTEST\TEMP) LFAdjustDest($LFStartFolder,$LFCurrentFile,H:\PURE_C\PROJECTS\VISION\IMGTEST\TEMP) quality=90;compression=lzw
|
||||
|
||||
; We don't need this image window anymore
|
||||
close LFAdjustDest($LFStartFolder,$LFCurrentFile,H:\PURE_C\PROJECTS\VISION\IMGTEST\TEMP)
|
||||
|
||||
; Proceed with next file in the folder
|
||||
Endloop_Folder
|
||||
Reference in New Issue
Block a user