plot noise

조회 수: 3 (최근 30일)
ahmed
ahmed 2012년 2월 7일
답변: Sanchari 2024년 7월 25일
Hi,
Please, what the name of the function that plot this noise, I want to understand the work of this function, what is the appropriate titles of the horizontal and vertical coordinates after the plot the noise?
% Noisy step
step = 1+[ones([32 64]) ; zeros([32 64])];
noise = 0.1 * randn(size(step));
im = (step + noise);
im = double(im);
figure(1), clf;
subplot(1,2,1); imshow(im,[0,3]);
figure(2); clf; ;
plot(im(:,32));

답변 (1개)

Sanchari
Sanchari 2024년 7월 25일
Hello Ahmed,
The code provided here generates and plots a noisy step image. Here is a breakdown of the code and the appropriate titles for the horizontal and vertical coordinates:
1. Generating the Step Image: The following code creates a 64x64 matrix "step" where the top half (32 rows) is filled with ones, and the bottom half (32 rows) is filled with zeros. Adding 1 to the entire matrix makes the top half filled with 2s and the bottom half filled with 1s.
step = 1 + [ones([32 64]) ; zeros([32 64])];
2. Adding Noise: This adds Gaussian noise with a standard deviation of 0.1 to the step image. The "randn" function generates normally distributed random numbers. The resulting noisy image is stored in "im".
noise = 0.1 * randn(size(step));
im = (step + noise);
im = double(im);
3. Displaying the Noisy Step Image: This displays the noisy step image using the "imshow" function. The [0, 3] range specifies the display range for the image.
figure(1), clf;
subplot(1,2,1); imshow(im, [0, 3]);
4. Plotting a Column of the Noisy Image: This plots the values of the 32nd column of the noisy image. The "plot" function is used to create the plot.
figure(2); clf;
plot(im(:,32));
When plotting the noisy step image and the column of the noisy image, appropriate titles for the horizontal and vertical coordinates can help in understanding the data. Here's a sample code including the same:
% Generate the step image
step = 1 + [ones([32 64]) ; zeros([32 64])];
% Add Gaussian noise
noise = 0.1 * randn(size(step));
im = (step + noise);
im = double(im);
% Display the noisy step image
figure(1), clf;
subplot(1,2,1);
imshow(im, [0, 3]);
title('Noisy Step Image');
xlabel('Pixel Column');
ylabel('Pixel Row');
% Plot the values of the 32nd column of the noisy image
figure(2); clf;
plot(im(:,32));
title('Intensity Values of the 32nd Column');
xlabel('Pixel Row Index');
ylabel('Intensity Value');
Output for the above code:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by