## bitcoin

### Drawing Shapes by Overwriting Pixel Value

1. How to highlight certain portion on an image?
The basic concept of highlighting part of an image is “Overwriting Pixel Value” on the image. We start from the basic idea on how to mask portion of image with blank sub-image (black color sub-image). Fig 1 shows the image with the size of 128x128x3 in which 3 represent s RGB. (In grayscale image 3 layers are the same). The image at the right hand site shows a blank sub-image is placed at the upper left of the original image. The MATLAB® code to perform the operation are as follow:

imshow(S);
Sblack = uint8(zeros(20,20,3));
S2 = S;
S2(1:20,1:20,:) = Sblack;
imshow(S2);

Fig 1

2. How to create a color mask rather than black color mask?
Since the 3 layers of image matrix represent RGB layers of the image, we can create the red color mask using following command, and the results are shown in fig 2.

Sred = Sblack;
Sred(:,:,1)=255;
S2 = S;
S2(1:20,1:20,:) = Sred;
imshow(S2);

Fig 2

3. How to create a transparent mask?
Simple enough, just play with the values R value, and perform the image addition rather than overwriting the value as follow:

Sred = Sblack;
Sred(:,:,1)=200;
S2 = S;
S2(1:20,1:20,:) = S2(1:20,1:20,:) + Sred;
imshow(S2);

Fig 3

4. Finally, how to create an outline for the image?

linelength = 10;
Sblack = uint8(zeros(128+linelength*2,128+linelength*2,3));
S2 = Sblack;
S2((1+linelength):(end-linelength),(1+linelength):(end-linelength),:)=S;
imshow(S2);

Fig 4

The “linelength” variable is the outline length in pixel.

* MATLAB® is the registered trademarks for The MathWorks, Inc