4 tutorial writers: Getting rid if blackenss from MFDs and space (some PNGs)

Enjo

Mostly harmless
Addon Developer
Tutorial Publisher
Donator
Joined
Nov 25, 2007
Messages
1,665
Reaction score
13
Points
38
Location
Germany
Website
www.enderspace.de
Preferred Pronouns
Can't you smell my T levels?
Hi

If you were ever making a tutorial and and were thinking about making a printable version of it, then you were surely pondering how much ink/toner the MFDs blackness printing would take. One solution would be to make a negative of the image, but then, you loose proper colors, which as you may guess, is very uneducational.

I've made a Matlab / Scilab script, which converts blackness into whiteness and vice versa, so the white writings are still visible. Here's a demo:

matlab-whitening.png


You can even allow for whitening of buttons, by making a screenshot in no panel view and while having transparent MFDs:

matlab-whitening3.png


[EDIT] The visible stars problem has been solved. See my post below

The script works on Matlab with Image Processing toolbox installed, and in Scilab with Scilab Image Processing toolbox but the latter failed to run on my Windows machine. Linux should do it.
If you don't have Matlab, then you can send me your set of images along with a script containing the images' names such as the following example:

Code:
image=imread([COLOR=red]'aerobrakeMFD_01.png'[/COLOR]);
image_out = img_whitening(image);
figure
imshow(image_out);
imwrite(image_out, [COLOR=red]'aerobrakeMFD_01_w.png'[/COLOR]);

image=imread([COLOR=red]'aerobrakeMFD_02.png'[/COLOR]); 
image_out = img_whitening(image,1); [COLOR=SeaGreen]% additionaly remove the stars[/COLOR]
figure
imshow(image_out);
imwrite(image_out, [COLOR=red]'aerobrakeMFD_02_w.png'[/COLOR]);

image=imread([COLOR=red]'aerobrakeMFD_09.png'[/COLOR]);
image_out = img_whitening(image,1); [COLOR=SeaGreen]% additionaly remove the stars[/COLOR]
figure
imshow(image_out);
imwrite(image_out, [COLOR=red]'aerobrakeMFD_09_w.png'[/COLOR]);
Notice that the only thing that you need to change is the filename. All the rest is just Copy Paste.

Here's the img_whitening() function:

Code:
function [image_out] = img_whitening(image, star_elimination);
%
% Whitens blackness of MFDs' background and space from an image passed as 
% the first parameter. Pass a second integer parameter to remove stars from 
% the picture. The stars removing may do wonders to panels so use it only
% if neccessary

[x y z]=size(image);
image_out = image;
for i=1:x     % width
    for j=1:y    % heigth
        sum_black = 0;    
        sum_grey = 0;
        star = true;
        % a check to avoid index excession
        if i > 1 && j > 1 && i < x && j < y
            % check if all pixels adjacent to this one have different
            % colors. If yes, then we have hopefully identified a star
            k = 1;  % we only need one channel 
            if image(i-1,j,k)   == image(i,j,k) && star == true  star = false; end;
            if image(i-1,j-1,k) == image(i,j,k) && star == true  star = false; end;
            if image(i  ,j-1,k) == image(i,j,k) && star == true  star = false; end;
            if image(i+1,j-1,k) == image(i,j,k) && star == true  star = false; end;
            if image(i+1,j,k)   == image(i,j,k) && star == true  star = false; end;
            if image(i+1,j+1,k) == image(i,j,k) && star == true  star = false; end;
            if image(i  ,j+1,k) == image(i,j,k) && star == true  star = false; end;
            if image(i-1,j+1,k) == image(i,j,k) && star == true  star = false; end;
        end;       
        if nargin == 1  star = false;  end;
        for k=1:z    % RGB channel (3 of them)
            % if this pixel in this channel is black...
            if image(i,j,k) == 0    sum_black=sum_black+1; end;         
            if star == false 
                % if this pixel in this channel is very bright...
                if image(i,j,k) > 230   sum_grey=sum_grey+1; end;    
                % if it is a star, then we're making the pixel white
            else  image_out(i,j,k) = 255;    end;
        end;
        if sum_black==z      % if all channels of this pixel were black
            for k=1:z image_out(i,j,k) = 255;    end;     % make white
        end
        if sum_grey==z      % if all channels of this pixel were bright
            for k=1:z   image_out(i,j,k) = 0;    end;    % make black
        end
    end
end
It should be possible to create an external program, using ImageMagick 's C++ API, but this would take some more time.
 
Last edited:
  • Like
Reactions: Tex

Cornflake

New member
Joined
Feb 5, 2008
Messages
117
Reaction score
3
Points
0
Location
Colorado, USA
Wow thanks, this should certainly come in handy.

Now we need to find a way to make skyboxes work in Orbiter, to make some interesting backdrops... I get tired of black space with boring white specs while cruising :p
 

Enjo

Mostly harmless
Addon Developer
Tutorial Publisher
Donator
Joined
Nov 25, 2007
Messages
1,665
Reaction score
13
Points
38
Location
Germany
Website
www.enderspace.de
Preferred Pronouns
Can't you smell my T levels?
I have updated the script to make it remove the stars, as an option.

mfd_whitening_stars.png



The stars removal does wonders to panels, so it's optional. When you use panels, then you won't need to remove the stars.

Script is updated in the first post
 

polaris149Tiberius

Tutorial Publisher
Tutorial Publisher
Joined
Apr 12, 2008
Messages
192
Reaction score
2
Points
0
Website
www.101stAirborneDivisionClan.com
I have been reading them

I have been reading them I love your MFD!!! I use it in almost every single launch I do. Keep on making your MFD docs and other MFDs PLEASE!!
Thanks for the work you have done.
 

tblaxland

O-F Administrator
Administrator
Addon Developer
Webmaster
Joined
Jan 1, 2008
Messages
7,320
Reaction score
25
Points
113
Location
Sydney, Australia
4 tutorial writers

And here I was expecting a story about The 4 Tutorial Writers... :p

Nice script, though. :cheers:
 
Top