Recent

Author Topic: How can i convert multi color to Black and White ??  (Read 4864 times)

majid.ebru

  • Hero Member
  • *****
  • Posts: 505
How can i convert multi color to Black and White ??
« on: October 14, 2017, 08:21:28 pm »
HI
How can i convert multi color to Black and White ?

in image down :
 how can i convert blue rang color to black&White rang color ??

thank you

lainz

  • Hero Member
  • *****
  • Posts: 4470
    • https://lainz.github.io/

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: How can i convert multi color to Black and White ??
« Reply #2 on: November 14, 2017, 02:59:25 pm »
Very simple

pseudo code :

Code: Pascal  [Select][+][-]
  1. Const
  2.   Thresold = 128;
  3.  
  4. For y:=0 to Img.Height-1
  5.   for  x:=0 to Img.Width -1
  6.   begin
  7.     Pixel := img.GetPixel(x,y);    
  8.     Intensity := (Pixel.Red+Pixel.Green+Pixel.Blue) div 3;
  9.     if intensity <  Thresold then newPixel:= clBlack else newPixel:= clWhite;
  10.     BWImg.PutPixel(x,y,NewPixel);
  11.  end;
  12.  

   

Thaddy

  • Hero Member
  • *****
  • Posts: 14381
  • Sensorship about opinions does not belong here.
Re: How can i convert multi color to Black and White ??
« Reply #3 on: November 14, 2017, 04:46:45 pm »
Very simple
It IS simple but not for gray scaling. And that was the question. First answer is correct.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: How can i convert multi color to Black and White ??
« Reply #4 on: November 14, 2017, 10:02:08 pm »
The main question is 
Quote
How can i convert multi color to Black and White ??
not to grayscale

The 2nd is for grayscale
Quote
how can i convert blue rang color to black&White rang color ??

So by the way now they have the choice  :P
« Last Edit: November 14, 2017, 10:03:51 pm by BeanzMaster »

 

TinyPortal © 2005-2018