- 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:
You can even allow for whitening of buttons, by making a screenshot in no panel view and while having transparent MFDs:
[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:
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:
It should be possible to create an external program, using ImageMagick 's C++ API, but this would take some more time.
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:
You can even allow for whitening of buttons, by making a screenshot in no panel view and while having transparent MFDs:
[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]);
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
Last edited: