在圖片中添加文字@lwx228問如何將文字新增至已載入影像的儲存格?這個想法很簡單:將圖片放入框架框中,使用圖形腳本進行裝飾,拍攝一張新照片。 獲得漂亮的往返影像的細節有點複雜。 需要調整框架的大小和比例,定位圖片,並裁剪最終圖像。
// open the original
original = New Image(
"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Oroblanco_%28sweetie%29_fruits.jpg/320px-Oroblanco_%28sweetie%29_fruits.jpg"
);
{xSize, ySize} = original << size;
// use a frame to do the drawing, make the original fit the frame exactly
gb = Graph Box(
<<BACKGROUNDCOLOR></BACKGROUNDCOLOR>
下面的結果顯示了用裝飾填滿框架框的圖像,以及下面的三張圖像。 左圖為原圖,中圖為修改後的圖,右圖為差異圖。 差別主要是黑色,沒有變化,這很好。 差異中的文字是模糊的,因為抗鋸齒在文字邊緣產生了細微的變化。
Circles and text added on top of fruit picture.Circles and text added on top of fruit picture.Circles and text added on top of fruit picture.Circles and text added on top of fruit picture.Circles and text added on top of fruit picture.Circles and text added on top of fruit picture.Circles and text added on top of fruit picture.Circles and text added on top of fruit picture.在水果圖片頂部添加圓圈和文字。
圖片來自裁切 JPG 影像解釋作物如何運作。
看更多...
Use a graphics frame box to add text and lines on top of a picture.Use a graphics frame box to add text and lines on top of a picture.Use a graphics frame box to add text and lines on top of a picture.Use a graphics frame box to add text and lines on top of a picture.Use a graphics frame box to add text and lines on top of a picture.Use a graphics frame box to add text and lines on top of a picture.Use a graphics frame box to add text and lines on top of a picture.Use a graphics frame box to add text and lines on top of a picture.使用圖形框架框在圖片頂部添加文字和線條。
使用框架框為圖片添加文字和線條。
回覆:在圖片中加入文字是的。有點難,下面解釋。
// open the original
original = New Image(
"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Oroblanco_%28sweetie%29_fruits.jpg/320px-Oroblanco_%28sweetie%29_fruits.jpg"
);
{xSize, ySize} = original << size;
overlay1 = new image("https://us.v-cdn.net/6038925/uploads/images/35680iA0171FFF13D53E06/NaturalCat.png");// cat
{xOverlay1Size, yOverlay1Size} = overlay1 << size;
dt = open("$sample_data/big class families.jmp","invisible");
overlay2 = dt:picture[1];// katie
overlay2<<SCALE></SCALE>
<P> </P>
<P><SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pictures added over another picture." style="width: 971px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="Pictures added over another picture." style="width: 971px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="Pictures added over another picture." style="width: 971px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="Pictures added over another picture." style="width: 971px;"><span class="lia-inline-image-display-wrapper" image-alt="Pictures added over another picture." style="width: 971px;"><img src="https://us.v-cdn.net/6038925/uploads/images/43745i912405FE3CFBC3E8/PicturePlusPicture.png" role="button" title="PicturePlusPicture.png" alt="Pictures added over another picture." /><span class="lia-inline-image-caption" onclick="event.preventDefault();">Pictures added over another picture.</span></span><SPAN class="lia-inline-image-caption" onclick="event.preventDefault();">Pictures added over another picture.</SPAN></SPAN><SPAN class="lia-inline-image-caption" onclick="event.preventDefault();">Pictures added over another picture.</SPAN></SPAN><SPAN class="lia-inline-image-caption" onclick="event.preventDefault();">Pictures added over another picture.</SPAN></SPAN><SPAN class="lia-inline-image-caption" onclick="event.preventDefault();">圖片添加到另一張圖片。</SPAN></SPAN></P>
<P>圖形腳本無法新增圖片。使用 < <ADDIMAGE message="" instead.=""><></ADDIMAGE></P><P> </P>
<P>GraphBox(...) 函數採用三種參數:參數、訊息和腳本。最佳實踐是將參數和訊息放在前面,將單一腳本放在最後。參數和訊息以逗號分隔。該腳本使用分號來分隔語句。</P>
<P> </P>
<CODE class=" language-jsl">gb = Graph Box(
<<BACKGROUNDCOLOR></BACKGROUNDCOLOR>
<P> </P>
<P>很多很多圖形框腳本都是偶然使用逗號而不是分號寫的。每個逗號都會導致一個新腳本開始,與前一個腳本分開。當一個腳本運行時,JMP 會執行多個腳本,這會產生一點額外的開銷。</P>
<P> </P>回覆: 在圖片上新增文字dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
p1 = dt << Graph Builder(
Variables( X( :weight ), Y( :height ), Group X( :age ), Color( :sex ) ),
Elements( Bar( X, Y, Legend( 5 ), Response Axis( "X" ), Summary Statistic( "Sum" ) ) )
);
img = p1 << getpicture ;
{r,g,b,a} = img<<GETPIXELS></GETPIXELS>How can Remove white background?Thanks Experts!
回覆:在圖片中加入文字圖表的透明背景色
獲得透明背景的一種方法是儲存 SVG,然後編輯 SVG 以刪除背景矩形。您可以使用 Inkscape 等編輯器來完成此操作,也可以編寫 JSL 來完成此操作。
dt = Open( "$sample_data/big class.jmp" );
gb = dt << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) ),
SendToReport(
Dispatch( {}, "Graph Builder", FrameBox,
// I chose fedcba to be unique, used in patmatch below
{Background Color( -Hex To Number( "fedcba" ) )}
)
)
);
gb << savepicture( "$temp/temp.svg", "svg" );
txt = Load Text File( "$temp/temp.svg" );
Write( txt ); // to log, for debugging
/* remove something like this:
<G fill="#FEDCBA">
<RECT stroke="none" x="75.5" y="33.5" width="509" height="420"></RECT>
</G>
*/
rc = Pat Match( txt, "<G fill="\!">" + Pat Arb() >> BadFillPattern + "</G>" );
If( !rc,
Throw( "fill pattern not found" )
);
// the BadFillPattern occurs twice, for two different colors. remove cases of
// <RECT stroke="none" x="75.5" y="33.5" width="509" height="420"></RECT>
// (the svg command that puts a rectangle of color behind the graph's data.)
nfound = 0;
While( Pat Match( txt, BadFillPattern, "" ), nfound += 1 );
If( nfound != 2,
Throw( "nfound=" || Char( nfound ) )
);
Save Text File( "$temp/temp.svg", txt );
// I don't know how you'll load this file on windows to prove it is transparent.
Open( "$temp/temp.svg" ); // this *does* load it, but there is nothing behind it to show through.
// you can open in FireFox and fiddle with the background color to observe the transparency
FireFox background shows through the transparency.FireFox background shows through the transparency.FireFox 背景透過透明度顯示。
我知道有 Linux 工具可以將 SVG 轉換為透明 PNG。這些工具也可能存在於 Win 上。
編輯:許多未經測試的想法https://stackoverflow.com/questions/6589358/convert-svg-to-png-in-python
回覆: Add Text to a Picture是的,我現在一直在使用這個命令
run program(executable("I:\00\imdisplay\magick.exe"),options({"C:\3\A1.png -fuzz 0% -transparent white C:\3\A2.png"}));
https://stackoverflow.com/questions/12424018/how-to-replace-white-background-color-with-transparent-of-an-image-in-imagemagic