MATLAB: Sir plz help me to rectify this error

digital image processing

X=reshape(x,size(Y));
where x=1; and Y=256 * 256 uint8
I got the error like this
"To RESHAPE the number of elements must not change."

Best Answer

Since x=1, you can use ones():
X = ones(size(Y)); % X is a double

If x is not one, but some other scalar, then you can use.
X = x * ones(size(Y)); % X is a double
If you want X to also be uint8, pass that class in:
X = ones(size(Y), 'uint8'); % Now X will also be uint8
Related Question