Sign in to follow this  
Followers 0
monoceres

Combine 3 images into one

7 posts in this topic

Ehm so this is just me playing around with bitmaps, so don't expect anything too fancy here...

This script basically combines three images into one by saving the first image in the red channel, the second in the green and the third in the blue channel. This means that the output image will still work as any other image, just that the image seem to be a blend of all three with the colors f-d up.

However it's still possible to retrieve monochrome versions of the images (which is the point with the entire script), by using some tricks in photo editing software. For example, in photoshop you can use the following procedure:

  • Open the image
  • Go to Image->Adjustments->Channel mixer
  • Check "monochrome" and then reset all values to 0 except for the channel you want to view, that one you set to 100.
Here's the script:

Combiner.au3

And here's an image I combined:

http://monoceres.se/Uploads/output.png

Ps.

It should work with most images, but if you have any problems convert your images into 24-bit uncompressed .bmp files and everything should work ok.

:)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites



@monoceres

Nice effect.

Combiner.au3 (73) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$aData[$col][$row] = BitXOR($aData[$col][$row], "0x0000" & $average)

It crashed at 2/3 of the process, 3 tests with different images.

Should the 3 images have exactly the same height and width maybe?

Greencan


Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Nice work but how about a preview before saving the image?

  • file name will be saved without extension (png)
  • saved image is bmp although you can select jpg, png.
UEZ

PS: I sent you a message - did you get it?

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks everyone :)

@monoceres

Nice effect.

Combiner.au3 (73) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$aData[$col][$row] = BitXOR($aData[$col][$row], "0x0000" & $average)

It crashed at 2/3 of the process, 3 tests with different images.

Should the 3 images have exactly the same height and width maybe?

Greencan

The first image need to be the largest, forgot to mention that.

Nice work but how about a preview before saving the image?

  • file name will be saved without extension (png)
  • saved image is bmp although you can select jpg, png.
UEZ

PS: I sent you a message - did you get it?

The preview is easy to implement, not sure if it's needed though..

The extension works if you actually type the the extension yourself in the dialog. Not sure how to fix it, since I cannot see a way to see what filter the user chose.

Oh right, I remember I got a message and then forgetting about it, I'll look again and post and answer real soon :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Nice work monoceres. I have only a question. I used this code to split a bitmap on every channel and when I combine the bitmaps, results a bitmap like first but a little more dark. Have an idea why?

This is the code that I use to split channels:

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <Color.au3>
#include <WinAPI.au3>

$PATH = FileOpenDialog("IMAGE",@DesktopDir,"Bitmaps (*.bmp)",1)
$CHOOSE = GUICreate("Choose",100,60,-1,-1,0x16C80000)
$COMBO = GUICtrlCreateCombo("",5,5,90,20)
GUICtrlSetData($COMBO,"RED|GREEN|BLUE","RED")
$SELECT = GUICtrlCreateButton("OK",5,30,90,20)
GUISetState(@SW_SHOW,$CHOOSE)
While 1
    $MSG = GUIGetMsg()
    If $MSG = $SELECT Then
        $CHANNEL = GUICtrlRead($COMBO)
        GUIDelete($CHOOSE)
        ExitLoop
    ElseIf $MSG = -3 Then
        Exit
    EndIf
    Sleep(15)
WEnd

$SAVE = FileSaveDialog("SAVE",@ScriptDir,"Bitmap (*.bmp)",16,"Bitmap_" & $CHANNEL)
If @error Then 
    $SAVE = @ScriptDir & "\Bitmap.bmp"
Else
    $SAVE = $SAVE & ".BMP"
EndIf

_GDIPlus_Startup()
$IMAGE = _GDIPlus_ImageLoadFromFile($PATH)
$X = _GDIPlus_ImageGetWidth($IMAGE)
$Y = _GDIPlus_ImageGetHeight($IMAGE)
_GDIPlus_ImageDispose($IMAGE)

$GUI = GUICreate("GDI+",$X,$Y,-1,-1,0x80000000)
GUISetBkColor(0xFFFFFF)
$PICTURE = GUICtrlCreatePic($PATH,0,0,$X,$Y)
GUISetState(@SW_SHOW,$GUI)

$DC = _WinAPI_GetDC($GUI)
$C_DC = _WinAPI_CreateCompatibleDC($DC)
$BITMAP = _WinAPI_CreateCompatibleBitmap($DC,$X,$Y)
_WinAPI_SelectObject($C_DC,$BITMAP)
_WinAPI_BitBlt ($C_DC,0,0,$X,$Y,$DC,0,0,$SRCCOPY)
$BITS = DllStructCreate ("dword[" & ($X * $Y) & "]")
DllCall ("gdi32", "int", "GetBitmapBits", "ptr", $BITMAP, "int", ($X * $Y * 4), "ptr", DllStructGetPtr ($BITS))
GUICtrlDelete($PICTURE)

For $CY = 0 To ($Y - 1)
    For $CX = 0 To ($X - 1)
        $INDEX = ($CY * $X) + $CX
        $COLOR = DllStructGetData ($BITS,1, $INDEX)
        $RED = Hex(_ColorGetRed($COLOR),2)
        $GREEN = Hex(_ColorGetGreen($COLOR),2)
        $BLUE = Hex(_ColorGetBlue($COLOR),2)
        If $CHANNEL = "RED" Then
            $COLOR = "0x" & $RED & "0000"
        ElseIf $CHANNEL = "GREEN" Then
            $COLOR = "0x00" & $GREEN & "00"
        ElseIf $CHANNEL = "BLUE" Then
            $COLOR = "0x0000" & $BLUE
        EndIf
        DllStructSetData ($BITS,1,$COLOR,$INDEX)
    Next
    DllCall ("gdi32", "int", "SetBitmapBits", "ptr", $BITMAP, "int", ($X * $Y * 4), "ptr", DllStructGetPtr ($BITS))
    _WinAPI_BitBlt ($DC,0,0,$X,$Y,$C_DC,0,0,$SRCCOPY)
Next
$HIMAGE = _GDIPlus_BitmapCreateFromHBITMAP($BITMAP)
_GDIPlus_ImageSaveToFile($HIMAGE,$SAVE)
_WinAPI_DeleteObject($HIMAGE)
_WinAPI_DeleteObject($BITMAP)
_GDIPlus_Shutdown()
_WinAPI_ReleaseDC($GUI,$DC)

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0