0
votes

I am using MATLAB 2015b to make a synthetic image as following (without green circle)

enter image description here

It maybe hard to make the star image for me. Hence, I used a simple shape as square as below code. However, I cannot create similar intensity as example image. If it is possible, would you help me to make the image? I think that the image has two components: intensity following Gaussian distribution and inhomogeneous intensity. Thank all

%% Gray image
rows = 256;
columns = 256;
grayImage = ones(rows, columns, 'uint8').*200;
xCoords= [80 180 180 80 80];
yCoords = [80 80 180 180 80];
mask = poly2mask(xCoords, yCoords, rows, columns);
grayImage(mask) = 80; 
%% First component Gray+noise
im_normal=double(grayImage./max(grayImage(:)));
im_noise= imnoise(im_normal,'gaussian',0,0.02);
%% Second component: Inhomogeneous term
X = 1:rows;                           % X is a vector from 1 to imageSize
X0 = (X / rows) -0.2;                 % rescale X 
Xm = meshgrid(X0, X0);             % 2D matrices
%% Output image
Out_Img=im_noise.*Xm;
subplot(121);imshow(grayImage);
subplot(122);imshow(Out_Img,[]);

This is my current result

enter image description here

1
First of all, if you look at your example image, the background is grey rather than black. It also appears that the amplitude of the noise is higher inside of the shape. - Suever
Thanks. I updated it - Jame
What exactly are the characteristics you want to reproduce? - zeeMonkeez
My target is how can I make a synthematic image as star image in MATLAB. Currently, I have no idea how to make it. The code what I write, it just my knowledge about the image. I am not sure it is true or not - Jame

1 Answers

0
votes

I would try the following approach:

  1. Find an approximation for the homogeneity field of the star image using gaussian blur:

    homogeneity = imfilter(I,fspecial('disk',15),'replicate');

  2. subtract the homogeneity field from the input image.

  3. Segment the star shape manually

  4. Calculate the histogram of the star using imhist function and the segmentation mask from previous stage. Divide it by the sum of the histogram. Thus you will get the probability vector which represents the star.

  5. do the same thing with the background - calculate the probability vector which represents the background.

  6. when generating the output:

    a. for each pixel inside of the square, generate a grayscale value randomly, using the probability vector from stage 2.

    b. for each background pixel, generate a grayscale value randomly using the probability vector from stage 3.

    c. finally - add the homogeneity field from stage 1 to your result.