Directly on the code:
Close All;import java.util.arraylist;import java.util.iterator;import java.util.list;import java.io.*;import Java.awt.*;import Java.awt.image.bufferedimage;import Java.awt.image.bufferedimage.*;import Javax.imageio.ImageIO ; h = 700;w = 500;image = BufferedImage (W, H, Bufferedimage.type_int_rgb); Graphics = Image.getgraphics (); Graphics.setrenderinghint (renderinghints.key_antialiasing, renderinghints.value_antialias_on); Fills the specified rectangular area with color graphics.setcolor (color.white); %green: Green, red: red; Grey: Graygraphics.fillrect (0, 0, W, h);% fills the specified rectangular area with color graphics.setcolor (color.white); Graphics.fillrect (240, 0, 240, 720) ; Graphics.setcolor (color.black);% draw Straight line x=100,y=100,x1=150,y1=y + 200; Graphics.drawline (X,Y,X+X1,Y1); % polygon Xpoints = [90,100,250,250];ypoints = [180,150,150,180]; Graphics.drawpolyline (Xpoints, ypoints, 4);% ellipse xoval=100,yoval=360; Graphics.drawoval (Xoval, Yoval, 150, 130); % text graphics.drawstring (' Straight line ', 100+50,100-5); Graphics.dispose (); Imageio.write (image, ' JPEG ', File (' testx.jpg ')); img =Imread (' testx.jpg '); Imshow (IMG);
Use Java API to draw graphics in MATLAB and save in JPEG format