I want to draw a sine wave in image and i want to save this image without plot. Because i cant save image with plot function as i want.

1 Kommentar

Stephen23
Stephen23 am 8 Jan. 2018
Bearbeitet: Stephen23 am 8 Jan. 2018
@umut: an image is just an array of numbers. There is nothing stopping you from changing some of an array's values, following any curve you wish. You do not need to plot anything to do this.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Guillaume
Guillaume am 8 Jan. 2018

1 Stimme

Simply calculate the coordinates of the pixels you want to set according to your equation. e.g:
img = zeros(200, 600); %demo image
numperiods = 8;
amplitude = 50; %pixels
offset = 100;
x = 1:0.25:size(img, 2); %pixel subsampling for better resolution
y = sin(x*2*pi/size(img, 2)*numperiods)*amplitude + offset;
img(sub2ind(size(img), round(y), round(x))) = 1;
imshow(img);

4 Kommentare

umut
umut am 8 Jan. 2018
thank you for answer, what should i do to apply a thicker wave ?
Image Analyst
Image Analyst am 8 Jan. 2018
Call imdilate(img, ones(9)) to thicken it by 9 pixels.
umut
umut am 8 Jan. 2018
sorry sir i asked so many question but this function thickens both letters and waves. I just want to thicken wave.
  • Create a new image the same size as your letter image
  • Draw the wave onto that new image
  • imdilate that new image
  • use that image as a mask to set pixels to 1 in your letter image
That last step is:
letterimage(logical(waveimage)) = 1; %assuming an image of type double

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 8 Jan. 2018

Kommentiert:

am 9 Jan. 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by