octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #56958] [Octave-Forge] (image) Implementation


From: Pantxo Diribarne
Subject: [Octave-bug-tracker] [bug #56958] [Octave-Forge] (image) Implementation of insertText
Date: Fri, 4 Dec 2020 16:59:34 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0

Follow-up Comment #9, bug #56958 (project octave):

If you want to go that route, I attached a file that should get you going.

Basically __text_to_pixels__ returns a  4-by-M-by-N RGBA unint8 array that you
can use to patch the image directly. Actually only the alpha map is usefull. 


[RGBA, bbox] = __text_to_pixels__ ("Hello", "FreeSerif", 50);
alpha = double (flipud (permute (RGBA(4,:,:), [3 2 1]))) / 255;

anchor_xy = [2, 40];
bbox = [anchor_xy bbox(3:4)];
idx_row =  bbox(2):(bbox(2)+bbox(4)-1);
idx_col =  bbox(1):(bbox(1)+bbox(3)-1);

fname = "/tmp/Capture.png"
im = im2double (imread (fname));
ncolor = 1;
if (numel (size (im)) == 3)
  ncolor = 3;
endif

fontcolor = [1 0 0];
for ii = 1:ncolor
  color = fontcolor(ii);
  im (idx_row, idx_col,ii) = im (idx_row, idx_col,ii) .* (1-alpha) + ...
                             color * ones (bbox(4),bbox(3)) .* alpha;
endfor
imshow (im, "colormap", copper ());



(file #50405)
    _______________________________________________________

Additional Item Attachment:

File name: __text_to_pixels__.cc          Size:1 KB
    <https://file.savannah.gnu.org/file/__text_to_pixels__.cc?file_id=50405>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56958>

_______________________________________________
  Message posté via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]