Thread Subject: create grayscale star sign

Subject: create grayscale star sign

From: Julia Woody

Date: 4 Jul, 2009 09:39:01

Message: 1 of 10

Hi all,

I have a 256x256 sized image as;

image=zeros(256,256)

and I want to create a grayscale colored star sign on this image. How to do this? what is the code for this?

Subject: create grayscale star sign

From: ImageAnalyst

Date: 4 Jul, 2009 13:34:46

Message: 2 of 10

On Jul 4, 5:39 am, "Julia Woody" <jwwoo...@gmail.com> wrote:
> Hi all,
>
> I have a 256x256 sized image as;
>
> image=zeros(256,256)
>
> and I want to create a grayscale colored star sign on this image. How to do this? what is the code for this?

---------------------------------------------------------------------------------------------------------
What does your star look like? I'd probably use poly2mask to create a
binary image and then use logical operations to "burn" it into your
original image. But you have to know the coordinates of the vertices
of the star of course because there are an infinite number of shapes
that you could call "stars."

Subject: create grayscale star sign

From: Julia Woody

Date: 4 Jul, 2009 14:37:01

Message: 3 of 10

thanks for your response
kind regards,
julia

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <0b84ba91-b15b-4dc1-9615-e9dff36570d8@s31g2000yqs.googlegroups.com>...
> On Jul 4, 5:39?am, "Julia Woody" <jwwoo...@gmail.com> wrote:
> > Hi all,
> >
> > I have a 256x256 sized image as;
> >
> > image=zeros(256,256)
> >
> > and I want to create a grayscale colored star sign on this image. How to do this? what is the code for this?
>
> ---------------------------------------------------------------------------------------------------------
> What does your star look like? I'd probably use poly2mask to create a
> binary image and then use logical operations to "burn" it into your
> original image. But you have to know the coordinates of the vertices
> of the star of course because there are an infinite number of shapes
> that you could call "stars."

Subject: create grayscale star sign

From: M. David

Date: 11 Aug, 2009 11:32:19

Message: 4 of 10

"Julia Woody" <jwwoody0@gmail.com> wrote in message <h2nped$glo$1@fred.mathworks.com>...
> thanks for your response
> kind regards,
> julia
>
> ImageAnalyst <imageanalyst@mailinator.com> wrote in message <0b84ba91-b15b-4dc1-9615-e9dff36570d8@s31g2000yqs.googlegroups.com>...
> > On Jul 4, 5:39?am, "Julia Woody" <jwwoo...@gmail.com> wrote:
> > > Hi all,
> > >
> > > I have a 256x256 sized image as;
> > >
> > > image=zeros(256,256)
> > >
> > > and I want to create a grayscale colored star sign on this image. How to do this? what is the code for this?
> >
> > ---------------------------------------------------------------------------------------------------------
> > What does your star look like? I'd probably use poly2mask to create a
> > binary image and then use logical operations to "burn" it into your
> > original image. But you have to know the coordinates of the vertices
> > of the star of course because there are an infinite number of shapes
> > that you could call "stars."

Hi,
I need a shape similar to star sign again, I want to draw the shape using cos function. 4 peaks (for north, south, west and east) will be enough for the star shape. Could you please give me example codes for this purpose

thanks, cheers

Subject: create grayscale star sign

From: ImageAnalyst

Date: 11 Aug, 2009 11:47:39

Message: 5 of 10

On Aug 11, 7:32 am, "M. David " <M.Da...@gmail.com> wrote:
> Hi,
> I need a shape similar to star sign again, I want to draw the shape using cos function.  4 peaks (for north, south, west and east) will be enough for the star shape. Could you please give me example codes for this purpose
>
> thanks, cheers- Hide quoted text -
>
> - Show quoted text -

---------------------------------------------------------------------
Why use a cos() function when all your vertices lie on the x and y
axes?
Just pick your 8 points and use the line() or plot() function - its
really trivial.

Subject: create grayscale star sign

From: M. David

Date: 11 Aug, 2009 12:01:19

Message: 6 of 10

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <267b4f57-eee0-4a13-8b53-d77765ab3e9e@r36g2000vbn.googlegroups.com>...
> On Aug 11, 7:32?am, "M. David " <M.Da...@gmail.com> wrote:
> > Hi,
> > I need a shape similar to star sign again, I want to draw the shape using cos function. ?4 peaks (for north, south, west and east) will be enough for the star shape. Could you please give me example codes for this purpose
> >
> > thanks, cheers- Hide quoted text -
> >
> > - Show quoted text -
>
> ---------------------------------------------------------------------
> Why use a cos() function when all your vertices lie on the x and y
> axes?
> Just pick your 8 points and use the line() or plot() function - its
> really trivial.

dear ImageAnalyst, thanks for your response.
the peaks must not be sharp. And, I will paint the inside of the shape with different color, and outside of the shape with different color. Also, the color of the shape itself must be with different color. How to do this?

Subject: create grayscale star sign

From: M. David

Date: 11 Aug, 2009 12:09:19

Message: 7 of 10

"M. David " <M.David@gmail.com> wrote in message <h5rmif$sg9$1@fred.mathworks.com>...
> ImageAnalyst <imageanalyst@mailinator.com> wrote in message <267b4f57-eee0-4a13-8b53-d77765ab3e9e@r36g2000vbn.googlegroups.com>...
> > On Aug 11, 7:32?am, "M. David " <M.Da...@gmail.com> wrote:
> > > Hi,
> > > I need a shape similar to star sign again, I want to draw the shape using cos function. ?4 peaks (for north, south, west and east) will be enough for the star shape. Could you please give me example codes for this purpose
> > >
> > > thanks, cheers- Hide quoted text -
> > >
> > > - Show quoted text -
> >
> > ---------------------------------------------------------------------
> > Why use a cos() function when all your vertices lie on the x and y
> > axes?
> > Just pick your 8 points and use the line() or plot() function - its
> > really trivial.
>
> dear ImageAnalyst, thanks for your response.
> the peaks must not be sharp. And, I will paint the inside of the shape with different color, and outside of the shape with different color. Also, the color of the shape itself must be with different color. How to do this?

I mean, there should not be any sharp corner. Deeps and the peaks should not be sharp

Subject: create grayscale star sign

From: ImageAnalyst

Date: 11 Aug, 2009 13:57:38

Message: 8 of 10

On Aug 11, 8:09 am, "M. David " <M.Da...@gmail.com> wrote:
> "M. David " <M.Da...@gmail.com> wrote in message <h5rmif$sg...@fred.mathworks.com>...
> > dear ImageAnalyst, thanks for your response.
> > the peaks must not be sharp.  And, I will paint the inside of the shape with different color, and outside of the shape with different color. Also, the color of the shape itself must be with different color. How to do this?
>
> I mean, there should not be any sharp corner. Deeps and the peaks should not be sharp- Hide quoted text -
>
----------------------------------------------------------------------------------------------------------
M. David:
Then just create an image with sharp vertexes, blur it, and then find
the new, smoother boundaries with bwboundaries. Save them to a mat
file, and then you can recall them, translate them if necessary, and
plot them as you need to.

Check out the patch() function if you want to fill the region.
Good luck,
ImageAnalyst

Subject: create grayscale star sign

From: M. David

Date: 11 Aug, 2009 16:20:17

Message: 9 of 10

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <9448389f-33c2-4239-808f-785b7f809d93@c2g2000yqi.googlegroups.com>...
> On Aug 11, 8:09?am, "M. David " <M.Da...@gmail.com> wrote:
> > "M. David " <M.Da...@gmail.com> wrote in message <h5rmif$sg...@fred.mathworks.com>...
> > > dear ImageAnalyst, thanks for your response.
> > > the peaks must not be sharp. ?And, I will paint the inside of the shape with different color, and outside of the shape with different color. Also, the color of the shape itself must be with different color. How to do this?
> >
> > I mean, there should not be any sharp corner. Deeps and the peaks should not be sharp- Hide quoted text -
> >
> ----------------------------------------------------------------------------------------------------------
> M. David:
> Then just create an image with sharp vertexes, blur it, and then find
> the new, smoother boundaries with bwboundaries. Save them to a mat
> file, and then you can recall them, translate them if necessary, and
> plot them as you need to.
>
> Check out the patch() function if you want to fill the region.
> Good luck,
> ImageAnalyst

Thanks a lot ImageAnalyst,

I am trying to change theta values of the following codes to obtain more oval corners instead of the sharp corners. Could you please examine the following codes:

t = (-1/4:1/28:3/4)*2*pi;
r1 = 44; r2 = 19;
r = (r1+r2)/2 + (r1-r2)/2*(-1).^[0:28];
x2 = r.*cos(t);
y2 = r.*sin(t);
plot(x2,y2,'b')

what should be the t values?
best regards

Subject: create grayscale star sign

From: ImageAnalyst

Date: 12 Aug, 2009 01:58:25

Message: 10 of 10

On Aug 11, 12:20 pm, "M. David " <M.Da...@gmail.com> wrote:
> Thanks a lot ImageAnalyst,
>
> I am trying to change theta values of the following codes to obtain more oval corners instead of the sharp corners. Could you please examine the following codes:
>
> t = (-1/4:1/28:3/4)*2*pi;
> r1 = 44; r2 = 19;
> r = (r1+r2)/2 + (r1-r2)/2*(-1).^[0:28];
> x2 = r.*cos(t);
> y2 = r.*sin(t);
> plot(x2,y2,'b')
>
> what should be the t values?
> best regards- Hide quoted text -
---------------------------------------------------------------------------------------------------------------
M.:
Try this instead (copy and paste but fix any line breaks introduced by
the newsreader):
Regards,
ImageAnalyst

% Demo macro to draw a rounded star (like a splat).
% by ImageAnalyst
clc;
close all;
clear all;
workspace;

% Select the inner and outer radius.
outerRadius = 44 % You can change this
innerRadius = 19 % You can change this
% Select the number of lobes around the circle.
numberOfLobes = 8; % You can change this

period = 2 * pi / numberOfLobes;
meanRadius = (outerRadius + innerRadius)/2
amplitude = (outerRadius - innerRadius)/2
t = (0:.005:1)*2*pi; % Independent parameter
variableRadius = amplitude * cos(2*pi*t/period) + meanRadius
subplot(2,2,1);
plot(variableRadius);
ylim([0 outerRadius]);
title('VariableRadius');
period = 2*pi; % Need to change this now.
x2 = variableRadius .* cos(2*pi*t/period);
y2 = variableRadius .* sin(2*pi*t/period);
subplot(2,2,2);
plot(t, x2);
title('x2 vs. t');
subplot(2,2,3);
plot(t, y2);
title('y2 vs. t');
subplot(2,2,4);
plot(x2,y2,'b')
title('x2 vs y2');

% Maximize window.
set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
cos M. David 11 Aug, 2009 07:34:21
namata Julia Woody 4 Jul, 2009 10:31:28
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com