Alpha Blending 2 Matrix Images
조회 수: 5 (최근 30일)
이전 댓글 표시
i have a 512 x512 matrix image called original, a 20x24 matrix image of a bright oval with lower (darker but not zero) values around the oval in the 20x24 matrix called insert, and the same 20x24 matrix image of the bright oval but with zeros around the oval and ones in the oval (binary image) called mask
and a mask of the oval in a 512 512 matrix
i want to place the matrix insert in a specific location in the matrix original (i know how to do this)
then i would want a spatially dependent alpha blender: so the mask can be used to know where the oval is in the 512x512 matrix and the alpha in those pixels would be 0(the pixel value would be 100% of the value in insert and nothing of the background original matrix) Then, pixel by pixel, as you get farther away from the oval, it blends the value of the pixel in the matrix insert and the pixel under the insert matrix(which would be in the original matrix) until it reaches the edge of the insert matrix (alpha would be 1 here meaning it is taking the value of 100% background original matrix and 0% if the insert matrix)
Can you please show me how to write code for this. I do not have examples or images i can provide
Thanks
댓글 수: 0
채택된 답변
Walter Roberson
2019년 10월 16일
Create a binary matrix in the shape of the oval. Take its complement. bwdistgeodesic() with the uncomplemented version. You now have an array of distances to the oval. Divide the array by max() of the array, which should be 1 at the outer edges. The array should get to be closer and closer to 0 as it gets closer to the oval.
댓글 수: 2
Walter Roberson
2019년 10월 17일
Example:
[X,Y] = ndgrid(-49:49);
Z = X.^2 + 2.*Y.^2 - X.*Y;
oval = Z <= 1000;
D = bwdistgeodesic(~oval, imdilate(oval, ones(3,3)));
alp = D ./ max(D(:));
alp(oval) = 0;
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!