How do I set image of picture to have white border on the left side?
b = imread('peppers.png');
b = im2double(b)
b(:,1:100) = 255;
imshow(b);
gives me like red border which doesn't have 100% opacity, how do i get white?
How do I set image of picture to have white border on the left side?
b = imread('peppers.png');
b = im2double(b)
b(:,1:100) = 255;
imshow(b);
gives me like red border which doesn't have 100% opacity, how do i get white?
It seems likely based on your question that the image loaded from 'peppers.png' is a color image.
You can check by typing
size(b)
into the command line. If it's a grayscale image, then the size will probably be something like
ans =
200 100
assuming your image is 200 x 100 in size. But if it's a color image, as I suspect, then the size will be something like
ans =
200 100 3
That third dimension holds the three color channels (red, green, and blue).
When you execute
b(:, 1:100) = 255;
you haven't specified which of the color channels you're indexing, so MATLAB implicitly assumes you're indexing the first channel, which is the red channel. So you are effectively doing this:
b(:, 1:100, 1) = 255;
But you don't want to just set the red channel to 255. To get a white border, you need the red, green, and blue channels to all be 255. Thus what you should do to get a white border is this:
b(:, 1:100, :) = 255;
That way you're indexing across all three color channels when you assign a value of 255, not just the red one.