%% Scale Display Range of Image
% Read a truecolor (RGB) image into the workspace. The data type of the image is uint8.

RGB = imread('peppers.png');

% Extract the green channel of the image. The green channel is the second color plane.

G = RGB(:,:,2);
imshow(G)

% Create a filter that blurs the image.

smoothing_filter = ones(5);

% Filter the green channel of the image using the filter2 function. The result is an image of data type double. The minimum pixel value is 165 and the maximum pixel value is 6,371.

J = filter2(smoothing_filter,G);

% Display the filtered image using imshow with the default display range. For images of data type double, the default display range is [0, 1]. The image appears entirely white because all pixel values exceed the maximum of the display range.

imshow(J)

% Display the filtered image and scale the display range to the pixel values in the image. The image displays with the full range of grayscale values.

imshow(J,[])

% Copyright 2020 The MathWorks, Inc.