MATLAB Answers

- You will see updates in your activity feed.
- You may receive emails, depending on your notification preferences.

17 views (last 30 days)

I want to plot a circle who's intensity varies as a Gaussian distribution, ie. to be maximum at the centre and tail off as the radius is increased. I have developed this code in which the intensity can vary according to the radius, but I am unsure on how to follow.

imagelength=100;

middle=(imagelength+1)/2;

radius=20;

dimmerRadius=15;

brightness=256;

dimmerBrightness=150;

image=ones(imagelength);

for i=1:imagelength

x=-imagelength+middle+i; %change y coordinate by adding term

for j=1:imagelength

y=-imagelength+middle+j; %change x coordinate by adding term

if(x^2+y^2<=radius^2) %equation of circle

image(i,j)=brightness;

end

if(x^2+y^2<=dimmerRadius^2)

image(i,j)=dimmerBrightness;

end

end

end

imagesc(image)

axis square

axis off

colormap gray

caxis([1 256])

Many thanks.

Image Analyst
on 12 Jun 2020

Image Analyst
on 20 Jun 2020

Sorry, no.

reham elnabawy
on 21 Jun 2020

Image Analyst
on 22 Jun 2020

Yes you can. Just edit out anything having to do with "big circle mask".

reham elnabawy
on 22 Jun 2020

Image Analyst
on 22 Jun 2020

OK, I deleted the lines of code for you:

% Demo to place multiple small circles of Gaussian profile

% Clean up

clc; % Clear the command window.

close all; % Close all figures (except those of imtool.)

imtool close all; % Close all imtool figures.

clear; % Erase all existing variables.

workspace; % Make sure the workspace panel is showing.

fontSize = 14;

% Initialize some parameters.

numberOfSmallCircles = 50; % Number of small circles

smallCircleOutsideValue = 0;

smallCircleInsideValue = 0.8;

smallCircleRadius = 31; % small circle radius

bigImageWidth = 500;

bigImageHeight = 500; % square area 0f 500*500

% Initialize an image to hold one single small circle.

sigma = smallCircleRadius * .4;

singleCircleImage = fspecial('gaussian', 2*smallCircleRadius, sigma);

% Normalize to 0-1.

singleCircleImage=singleCircleImage/max(max(singleCircleImage));

% Display it in the upper right plot.

subplot(1, 2, 1);

imshow(singleCircleImage, []);

title('Single Small Circle (scaled to fit)', 'FontSize', fontSize);

axis('on', 'image');

singleWidth = size(singleCircleImage, 2);

singleHeight = size(singleCircleImage, 1);

% Get random coordinates in the big image where

% we will place the upper left corner of the small circle.

widthThatWillFit = bigImageWidth - 2 * smallCircleRadius;

heightThatWillFit = bigImageHeight - 2 * smallCircleRadius;

smallUpperLeftX = widthThatWillFit * rand(numberOfSmallCircles, 1);

smallUpperLeftY = heightThatWillFit * rand(numberOfSmallCircles, 1);

% Initialize an output image to hold many small overlapping circles.

manySmallCircles = zeros(bigImageHeight, bigImageWidth);

% Place the small circles one by one.

for k = 1 : numberOfSmallCircles

% Find the square in the big image where we're going to add a small circle.

x1 = int16(smallUpperLeftX(k));

y1 = int16(smallUpperLeftY(k));

if x1 < 1

x1 = 1;

end

if y1 < 1

y1 = 1;

end

x2 = int16(x1 + singleWidth - 1);

y2 = int16(y1 + singleHeight - 1);

if x2 > bigImageWidth

x2 = bigImageWidth;

end

if y2 > bigImageHeight

y2 = bigImageHeight;

end

% Add in one small circle to the existing big image.

manySmallCircles(y1:y2, x1:x2) = manySmallCircles(y1:y2, x1:x2) + singleCircleImage;

end

% Make outside the circles the outside color.

manySmallCircles(manySmallCircles == 0) = smallCircleOutsideValue;

% Display it in the lower left plot.

subplot(1, 2, 2);

imshow(manySmallCircles, []);

title('Many Small Overlapping Circles', 'FontSize', fontSize);

axis('on', 'image');

reham elnabawy
on 22 Jun 2020

Image Analyst
on 22 Jun 2020

I don't get the center of the circle. We don't need it and won't use it. Each circle is a little square matrix that we need to paste onto the canvass so what we need is the starting and stopping rows and starting and stopping columns. I get the starting row and columns with these lines:

smallUpperLeftX = widthThatWillFit * rand(numberOfSmallCircles, 1);

smallUpperLeftY = heightThatWillFit * rand(numberOfSmallCircles, 1);

The small Gaussian image is singleCircleImage. If you don't want to drop/paste it onto a big black canvass like I did, you're perfectly welcome to past it onto some other canvass. If you don't want to paste it (assign it), you can ADD it to the canvass image. That way you'll still see some of the underlying canvass image.

reham elnabawy
on 23 Jun 2020

Image Analyst:

Where in your code do you drop/paste the singleCircleImage on your big black canvas?

As I have an image that is initially black and by means of imshow and hold on, I fill the circle to be drawn on top of this image and give the fill command the rgb color which is white. However, I need the circle to not be as if it is bitmapped however, I want the circle to be having luminance effect not just white color so that's why I just need to apply gaussian effect to the circle instead of coloring it so how could I do that please?

Image Analyst
on 23 Jun 2020

RIght here is where I drop the single circle onto the canvass that has all the other circles on it:

% Add in one small circle to the existing big image.

manySmallCircles(y1:y2, x1:x2) = manySmallCircles(y1:y2, x1:x2) + singleCircleImage;

manySmallCircles is the full-sized canvass, and singleCircleImage is the small image containing one single circle. Not sure what you mean by "bitmapped" because all images are essentially bitmapped. They are all discrete matrices of pixel values, discrete both spatially (rows and columns) and in intensity (gray levels). Note that my "circles" are not solid, one-intensity circles, they have a Gaussian profile. Zoom in and look closely. Look at the big image of the single circle - you can see there that it has a "gaussian effect to the circle" as you call it. So why do you say I'm "coloring" it instead of adding a Gaussian-profiled hump onto the image?

If you want color, there are several ways to do that depending on if you wanted replacement or addition. In my demo I'm doing addition. I think you might be able to make the single circle color and then just add a third dimension to the addition like this (untested):

% Add in one small RGB circle to the existing big RGB image.

manySmallCircles(y1:y2, x1:x2, :) = manySmallCircles(y1:y2, x1:x2, :) + singleCircleImage;

reham elnabawy
on 23 Jun 2020

Image Analyst
on 24 Jun 2020

Didn't I do that? How do my spots not have the Gaussian luminance effect???

reham elnabawy
on 24 Jun 2020

Image Analyst:

Yes you did that but as you can see, the circle drawn in your code is a set of pixels grouped together that is drawn based on the number of rows and the number of columns however, what I need to do is, that I need to draw the circle that has gaussian effect just the same view as yours before maximizing the figure so that there will be no pixelization shown. Or in other words, I need the circle to be a solid circle that has gaussian luminance effect instead of this pixelization effect so is there a way to do that?

Note: you can refer to the attached image named "reference image" to know the circle view that I need to reach.

Also, please refer to the second image named "bitmappedVsGaussian" where the left image is the image that I already reached in my own code however, I would like to reach the right hand side image

Image Analyst
on 24 Jun 2020

reham, that looks just like what I'm doing. I'm not doing what you call bitmapped - making solid discs of uniform gray level. It seems the only difference is you're putting your Gaussians on a regular hex grid and varying the Gaussian sigma. So when you do that to my code you get this:

% Demo to place multiple small circles of Gaussian profile

% Clean up

clc; % Clear the command window.

close all; % Close all figures (except those of imtool.)

imtool close all; % Close all imtool figures.

clear; % Erase all existing variables.

workspace; % Make sure the workspace panel is showing.

fontSize = 14;

% Initialize some parameters.

numberOfSmallCircles = 50; % Number of small circles

smallCircleOutsideValue = 0; % Background color.

smallCircleRadius = 15; % small circle radius

bigImageWidth = 470;

bigImageHeight = 349; % square area 0f 500*500

% fileName = 'reference image.png';

% grayImage = imread(fileName);

% [rows, columns, numColors] = size(grayImage)

% imshow(grayImage);

% impixelinfo;

xStart = 32;

xSpacing = 29;

yStart = 26;

ySpacing = 25;

x = xStart : xSpacing : bigImageWidth

y = yStart : ySpacing : bigImageHeight

[x, y] = meshgrid(x, y);

evenRows = 2 : 2 : size(x, 1);

x(evenRows, :) = x(evenRows, :) + 16;

x = x(:);

y = y(:);

hold on;

plot(x(:), y(:), 'r.', 'MarkerSize', 15);

% Initialize an image to hold one single small circle.

sigma = smallCircleRadius * .4;

singleCircleImage = fspecial('gaussian', 2*smallCircleRadius, sigma);

% Normalize to 0-1.

% singleCircleImage = singleCircleImage / max(singleCircleImage(:));

% Display it in the upper right plot.

subplot(2, 1, 1);

imshow(singleCircleImage, []);

title('Single Small Circle', 'FontSize', fontSize);

axis('on', 'image');

singleWidth = size(singleCircleImage, 2);

singleHeight = size(singleCircleImage, 1);

% Get random coordinates in the big image where

% we will place the upper left corner of the small circle.

widthThatWillFit = bigImageWidth - 2 * smallCircleRadius;

heightThatWillFit = bigImageHeight - 2 * smallCircleRadius;

smallUpperLeftX = x;

smallUpperLeftY = y;

% Initialize an output image to hold many small overlapping circles.

manySmallCircles = zeros(bigImageHeight, bigImageWidth);

% Place the small circles one by one.

for k = 1 : length(smallUpperLeftX)

% Find the square in the big image where we're going to add a small circle.

x1 = int16(smallUpperLeftX(k));

y1 = int16(smallUpperLeftY(k));

if x1 < 1

x1 = 1;

end

if y1 < 1

y1 = 1;

end

x2 = int16(x1 + singleWidth - 1);

y2 = int16(y1 + singleHeight - 1);

if x2 > bigImageWidth

continue;

end

if y2 > bigImageHeight

continue;

end

% Initialize an image to hold one single small circle.

sigma = smallCircleRadius * 0.5 * rand(1);

singleCircleImage = fspecial('gaussian', 2*smallCircleRadius, sigma);

% Normalize to 0-1.

singleCircleImage = singleCircleImage / max(singleCircleImage(:));

fprintf('Dropping Gaussian at upper left = (%d, %d).\n', x1, y1);

% Add in one small circle to the existing big image.

manySmallCircles(y1:y2, x1:x2) = manySmallCircles(y1:y2, x1:x2) + singleCircleImage;

% Display it in the lower left plot. This will slow it down though.

% subplot(2, 1, 2);

% imshow(manySmallCircles, []);

% title('Many Small Gaussians', 'FontSize', fontSize);

% axis('on', 'image');

% drawnow;

end

% Make outside the circles the outside color.

manySmallCircles(manySmallCircles == 0) = smallCircleOutsideValue;

% Display it in the lower left plot.

subplot(2, 1, 2);

imshow(manySmallCircles, []);

title('Many Small Gaussians', 'FontSize', fontSize);

axis('on', 'image');

Now what you said you want is this:

Tell me that they're much different. If so, then I'm sure a smart engineer like you will be able to modify my code, like modifying the amplitude as well (inside the loop of course) or whatever.

reham elnabawy
on 25 Jun 2020

Image Analyst:

Fristly, thank you for your help. Secondly, I think there is a misunderstand. I didn't talk about your code from the beginning, as I am talking about my code that I did before seeing your code where my code includes btmapped not gaussian circles. And while I was searching for how to perform gaussian luminance profile on my drawn circles, I found your code so I asked you the above questions. So off course, this means that it is obvious that you are applying the gaussian profile to the circle and I was trying to know how you did that and that's it :)

Last but not least, indeed your output image in your last comment is the same as what I attached to you. So there is no need to tell me "smart engineer" as if you are making fun of me, as I think you misunderstand me from the beginning. However, I would like to thank you again for your help and I will try your code and get back to you if I have a problem.

reham elnabawy
on 26 Jun 2020

Image Analyst:

I have a question please.

In your last code that you sent to me, you are doing the sigma in terms of a random value however, what I need to do is, that I don't want to get random circles lightened but I need the following:

There is an input image that is for example a flower and I would like to apply your code to this image so that the more brightened circles are the circles located at the foreground positions.

Note: please see the two attached images where the first image is the input image and the second image is the desired output image.

For more clarification, please also find attached another set of images named "input and output 2" where the left image is the input image and the right image is the output image.

Please note that I need the code to be generic so this means that the code should work on any input image.

Thank you in advance.

Image Analyst
on 26 Jun 2020

Try having sigma be a factor times the gray level at the center location. First read in your gray scale image, before the loop, then in the loop:

xMid = round(mean([x1,x2]));

yMid = round(mean([y1,y2]));

grayLevel = grayImage(yMid, xMid); % This changes depending on where in the image we are.

sigma = someFactor * grayLevel;

Figure out what someFactor needs to be. But it will probably be something like 0.01 or something. It will be the same for the whole program. someFactor does not vary location by location.

reham elnabawy
on 27 Jun 2020

Image Analyst:

I tried to add the lines of codes you wrote to your code but there was an error which is that the sigma is of type uint8 and it should be double so, I typecasted it to be double. However, after that error was fixed by adding double typecast, I found another which is index exceeds matrix dimensions from the following line:

grayLevel = grayImage(yMid, xMid);

So how to fix this error please?

Please find below the code after adding the image which is the grayscale flower image before the loop:

numberOfSmallCircles = 50; % Number of small circles

smallCircleOutsideValue = 0; % Background color.

smallCircleRadius = 15; % small circle radius

bigImageWidth = 470;

bigImageHeight = 349;

xStart = 32;

xSpacing = 29;

yStart = 26;

ySpacing = 25;

x = xStart : xSpacing : bigImageWidth

y = yStart : ySpacing : bigImageHeight

[x, y] = meshgrid(x, y)

evenRows = 2 : 2 : size(x, 1);

x(evenRows, :) = x(evenRows, :) + 16;

x = x(:);

y = y(:);

sigma = smallCircleRadius * .4;

singleCircleImage = fspecial('gaussian', 2*smallCircleRadius, sigma);

subplot(2, 1, 1);

imshow(singleCircleImage,[]);

title('Single Small Circle', 'FontSize', fontSize);

singleWidth = size(singleCircleImage, 2);

singleHeight = size(singleCircleImage, 1);

smallUpperLeftX = x;

smallUpperLeftY = y;

manySmallCircles = zeros(bigImageHeight, bigImageWidth);

inputImage = imread('flower.jpg');

grayImage=rgb2gray(inputImage);

% Place the small circles one by one.

for k = 1 : length(smallUpperLeftX)

% Find the square in the big image where we're going to add a small circle.

x1 = smallUpperLeftX(k);

y1 = smallUpperLeftY(k);

x2 = x1 + singleWidth - 1;

y2 = y1 + singleHeight - 1;

if x2 > bigImageWidth

continue;

end

if y2 > bigImageHeight

continue;

end

xMid = round(mean([x1,x2]));

yMid = round(mean([y1,y2]));

grayLevel = grayImage(yMid, xMid); % This changes depending on where in the image we are.

sigma = double(0.01 * grayLevel);

singleCircleImage = fspecial('gaussian', 2*smallCircleRadius, sigma);

% Normalize to 0-1.

singleCircleImage = singleCircleImage / max(singleCircleImage(:));

fprintf('Dropping Gaussian at upper left = (%d, %d).\n', x1, y1);

% Add in one small circle to the existing big image.

manySmallCircles(y1:y2, x1:x2) = manySmallCircles(y1:y2, x1:x2) + singleCircleImage;

end

% Display it in the lower left plot.

subplot(2, 1, 2);

imshow(manySmallCircles);

title('Many Small Gaussians', 'FontSize', fontSize);

Please fix this error for me. Also, I need another thing which is that I would like the spacing between every two consecutive gaussian circles to be a variable so that the user can easily change this variable to the desired distance between each two consecutive circles so what could be added to the code to achieve this?

Also, how to make the size of the circles as a variable so that the user will be able to enter the desired circle size? How to achieve this in the code?

Image Analyst
on 27 Jun 2020

Evidently your code requires flower.jpg, which you forgot to attach. I'll check back later.

If it doesn't like something because it's uint8, cast it to double:

sigma = 0.01 * double(grayLevel);

By the way, sorry my attempt at paying a compliment and providing encouragement by referring to you as a smart engineer fell flat.

To change the spacing, you change the spacing by adding a random value to the spacing so it won't be a constant anymore:

xStart = 32;

xSpacing = 29;

yStart = 26;

ySpacing = 25;

x = xStart : xSpacing : bigImageWidth

y = yStart : ySpacing : bigImageHeight

% Add a jitter to x and y by adding a random number.

jitterFraction = 0.10; % Percent of initial spacing you want

x = x + jitterFraction * xSpacing * rand(1, length(x));

y = y + jitterFraction * ySpacing * rand(1, length(y));

% Don't let x go below 1

x = max(x, 1);

y = max(y, 1);

x = min(x, bigImageWidth);

y = min(y, bigImageHeight);

reham elnabawy
on 27 Jun 2020

Image Analyst
on 27 Jun 2020

Here, try this. It's almost done but I've already spent too much time on it and I need to leave for for you to do so you'll feel some pride of ownership.

% Initialization steps. Brute force cleanup of everything currently existing to start with a clean slate.

clc; % Clear the command window.

fprintf('Beginning to run %s.m ...\n', mfilename);

close all; % Close all figures (except those of imtool.)

clear; % Erase all existing variables. Or clearvars if you want.

workspace; % Make sure the workspace panel is showing.

format long g;

format compact;

fontSize = 20;

inputImage = imread('flower.jpg');

grayImage = rgb2gray(inputImage);

subplot(2, 2, 1);

imshow(grayImage);

title('Original Image', 'FontSize', fontSize);

smallCircleRadius = 15; % small circle radius

bigImageWidth = size(grayImage, 2);

bigImageHeight = size(grayImage, 1);

xStart = 1;

xSpacing = round(bigImageWidth / 10);

yStart = 1;

ySpacing = round(bigImageHeight / 10);

x = xStart : xSpacing : bigImageWidth

y = yStart : ySpacing : bigImageHeight

[x, y] = meshgrid(x, y)

evenRows = 2 : 2 : size(x, 1);

x(evenRows, :) = x(evenRows, :) + 16;

x = x(:);

y = y(:);

% Add a jitter to x and y by adding a random number.

jitterFraction = 1.0; % Percent of initial spacing you want

x = round(x + jitterFraction * xSpacing * rand(length(x), 1));

y = round(y + jitterFraction * ySpacing * rand(length(y), 1));

% Don't let x go below 1

x = max(x, 1);

y = max(y, 1);

x = min(x, bigImageWidth);

y = min(y, bigImageHeight);

sigma = smallCircleRadius * .4;

singleCircleImage = fspecial('gaussian', 2*smallCircleRadius, sigma);

subplot(2, 2, 2);

imshow(singleCircleImage,[]);

title('Single Small Gaussian', 'FontSize', fontSize);

singleWidth = size(singleCircleImage, 2);

singleHeight = size(singleCircleImage, 1);

smallUpperLeftX = x(:);

smallUpperLeftY = y(:);

manySmallCircles = zeros(bigImageHeight, bigImageWidth);

% Place the small circles one by one.

for k = 1 : length(smallUpperLeftX)

% Find the square in the big image where we're going to add a small circle.

x1 = smallUpperLeftX(k);

y1 = smallUpperLeftY(k);

x2 = x1 + singleWidth - 1;

y2 = y1 + singleHeight - 1;

if x2 > bigImageWidth

continue;

end

if y2 > bigImageHeight

continue;

end

xMid = round(mean([x1,x2]));

yMid = round(mean([y1,y2]));

grayLevel = grayImage(yMid, xMid); % This changes depending on where in the image we are.

if grayLevel == 0

grayLevel = 1;

end

sigma = 0.02 * double(grayLevel);

singleCircleImage = fspecial('gaussian', 2*smallCircleRadius, sigma);

% Normalize to 0-1.

singleCircleImage = singleCircleImage / max(singleCircleImage(:));

fprintf('Dropping Gaussian %4d at upper left = (%d, %d) with sigma = %f.\n', k, x1, y1, sigma);

% Add in one small circle to the existing big image.

manySmallCircles(y1:y2, x1:x2) = manySmallCircles(y1:y2, x1:x2) + singleCircleImage;

end

% Plot the upper lefts

subplot(2, 2, 3);

plot(smallUpperLeftX + singleWidth/2, smallUpperLeftY + singleHeight/2, 'r.');

grid on;

axis ij;

title('Gaussian Points', 'FontSize', fontSize);

% Display it in the lower left plot.

subplot(2, 2, 4);

imshow(manySmallCircles, []);

title('Many Small Gaussians', 'FontSize', fontSize);

g = gcf;

g.WindowState = 'maximized';

reham elnabawy
on 28 Jun 2020

Image Analyst:

Firstly, thank you for your time and for your help. Secondly, I tried your last code and tried to get the shape of the flower in gaussian format just as the "output.png" image attached before, but I found that the shape of the output is no more hexagonal grid and it is as if sampling is amplied or a filter is applied to the flower where it is almost the same as the flower image but in blurred format. I tried to change the jitterfactor and someFactor but this doesn't yield to the desired output. Also, it is obvious that the shape of small circles turned to be square-like shape not a circle which is also not desired. Please find below the code after adding some updates to it. You can go to a script and write the following lines to call the function below:

I=imread('flower.jpg');

GaussianHexagonalGrid(I,0.5,0.5);

Where d and s are the distance between each two circles and the size of each circle respectively.

I will be really glad if you helped in this and I already can't thank you enough for your time to help me in the previous comments but please help me in this final thing and thank you for your kindness.

function [] = GaussianHexagonalGrid(I,d,s)

%% Read input image

fontSize=12;

grayImage = rgb2gray(I);

subplot(2, 2, 1);

imshow(grayImage);

title('Original Image', 'FontSize', fontSize);

%smallCircleRadius = 15; % small circle radius

bigImageWidth = size(grayImage, 2);

bigImageHeight = size(grayImage, 1);

xStart = 1;

%xSpacing = round(bigImageWidth / 10);

xSpacing = 10*d;

yStart = 1;

%ySpacing = round(bigImageHeight / 10);

ySpacing = 10*d;

x = xStart : xSpacing : bigImageWidth;

y = yStart : ySpacing : bigImageHeight;

[x, y] = meshgrid(x, y);

x = x(:);

y = y(:);

% Add a jitter to x and y by adding a random number.

jitterFraction = 1.0; % Percent of initial spacing you want

x = round(x + jitterFraction * xSpacing * rand(length(x), 1));

y = round(y + jitterFraction * ySpacing * rand(length(y), 1));

x = max(x, 1);%to make sure that x will not be below one

y = max(y, 1);%to make sure that y will not be below one

x = min(x, bigImageWidth);%to make sure that the current x will not exceed the bigImageWidth

y = min(y, bigImageHeight);%to make sure that the current y will not exceed the bigImageWidth

%% Hexagonal grid

evenRows = 2 : 2 : size(x, 1);

x(evenRows, :) = x(evenRows, :) + 16;

smallCircleRadius = 30*s;

sigma = smallCircleRadius * .4;

singleCircleImage = fspecial('gaussian', 2*smallCircleRadius, sigma);

subplot(2, 2, 2);

imshow(singleCircleImage,[]);

title('Single Small Gaussian', 'FontSize', fontSize);

singleWidth = size(singleCircleImage, 2);

singleHeight = size(singleCircleImage, 1);

smallUpperLeftX = x(:);

smallUpperLeftY = y(:);

manySmallCircles = zeros(bigImageHeight, bigImageWidth);

% Place the small circles one by one.

for k = 1 : length(smallUpperLeftX)

% Find the square in the big image where we're going to add a small circle.

x1 = smallUpperLeftX(k);

y1 = smallUpperLeftY(k);

x2 = x1 + singleWidth - 1;

y2 = y1 + singleHeight - 1;

if x2 > bigImageWidth

continue;

end

if y2 > bigImageHeight

continue;

end

xMid = round(mean([x1,x2]));

yMid = round(mean([y1,y2]));

grayLevel = grayImage(yMid, xMid); % This changes depending on where in the image we are.

if grayLevel == 0

grayLevel = 1;

end

sigma = 0.02 * double(grayLevel);

singleCircleImage = fspecial('gaussian', 2*smallCircleRadius, sigma);

% Normalize to 0-1.

singleCircleImage = singleCircleImage / max(singleCircleImage(:));

fprintf('Dropping Gaussian %4d at upper left = (%d, %d) with sigma = %f.\n', k, x1, y1, sigma);

% Add in one small circle to the existing big image.

manySmallCircles(y1:y2, x1:x2) = manySmallCircles(y1:y2, x1:x2) + singleCircleImage;

end

% Plot the upper lefts

subplot(2, 2, 3);

plot(smallUpperLeftX + singleWidth/2, smallUpperLeftY + singleHeight/2, 'r.');

grid on;

axis ij;

title('Gaussian Points', 'FontSize', fontSize);

% Display it in the lower left plot.

subplot(2, 2, 4);

imshow(manySmallCircles, []);

title('Many Small Gaussians', 'FontSize', fontSize);

end

Image Analyst
on 28 Jun 2020

To go back to a hex grid, remove the jitter. So remove these lines:

% Add a jitter to x and y by adding a random number.

jitterFraction = 0.10; % Percent of initial spacing you want

x = x + jitterFraction * xSpacing * rand(1, length(x));

y = y + jitterFraction * ySpacing * rand(1, length(y));

reham elnabawy
on 28 Jun 2020

Image Analyst:

Firstly, thank you for your kind response. Secondly, I removed the lines you told me to remove and I got back the hexagonal grid shape. However, the shape I obtained, as shown in the attached image(obtainedOutput.jpg), the flower pixels appear faded inside eachothers so how to get it not faded like the image in "desiredOutput.jpg" attached?

Image Analyst
on 30 Jun 2020

reham elnabawy
on 2 Jul 2020

Image Analyst:

ok. I got your point. I minimized the sigma value so that the blurriness is removed. However, I can see that the circle shape is dissapeared meaning that, all the circles are drawn now as squares as shown in the attached figure. So how could I reconstruct the circle shape ?

Image Analyst
on 2 Jul 2020

reham elnabawy
on 3 Jul 2020

Image Analyst
on 3 Jul 2020

Opportunities for recent engineering grads.

Apply TodayUnable to complete the action because of changes made to the page. Reload the page to see its updated state.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

## 0 Comments

Sign in to comment.