如何将squre图像融入弯曲的形状图像?

时间:2016-07-28 15:22:42

标签: matlab image-processing imaging

我想将QR码放入qr code曲面图像中。 我在MATLAB中使用极性形式以获得弯曲的形状,但我不知道如何将我的QR码拟合到这个非方形图像中。

this is the curved shape that i generate by MATLAB using polar form

揍你!

2 个答案:

答案 0 :(得分:1)

这是一个快速的“肮脏方法”

[QR, map] = imread ('qr.png'); % indexed image, so we need to also get the map            

QR = ind2gray (QR, map);       % convert to grayscale

QR = fliplr (QR);              % x-axis moves rightwards, whereas angle t moves 
                               % leftwards, therefore flip left-to-right                            

[r, t] = ndgrid (1 : size (QR, 1), 1 : size (QR, 2)); % rows as radius,
                                                      % columns as angle

t = mat2gray (t);                          % Normalize angle in [0,1] range
t = ((-t) * deg2rad (20)) - deg2rad (80);  % Convert to [80,100] range

r = mat2gray (r);                          % similar approach for radius range
r = (r * 5) + 15;             

X = r .* cos (t);                          % convert polar to cartesian
Y = r .* sin (t);                               

scatter (X(:), Y(:), 1, QR(:))             % plot each cartesian pair as a 
                                           % plot point of size 1, and colour
                                           % taken from the QR matrix
colormap gray;                            
axis off;

结果:

enter image description here

答案 1 :(得分:0)

I tried to sketch the QR code on a pie with parameters

同样,所有参数都已定义

我希望能帮助理解这个问题。