Matlab: Selecting a meshgrid subset and transform it with a conformal map
€8-30 EUR
Kulipwa wakati wa kujifungua
Preamble:
- This is a very small part of a non-commercial art project with a fixed budget of 30 EUR but no strict due date or deadline. A sufficient time intervall would be completion in 1 weeks.
- Making higher price bids than the budget or low price bids without reading the description and demanding more later is worthless and is only a waste of time for all stakeholders.
- Demanding a milestone release without me inspecting and testing the Matlab code will not be accepted.
THE TASK: Given is a RGB image (img), a gray mask (SF), and a complex valued function fz (like fz = 0.5*(z+(1./z))), that should be used to distort a region of img. A region in SF should be specified by a condition for example SF > 0. If an output-grid is generated the same size as SF a corresponding region can be specified in that grid and the transformation of the output-grid should be restricted to this grid subset:
if the corresponding SF-pixel to a gridpoint satisfy the given condition
transform gridpoint with fz;
end
Instead of iterating through the grid or using the slow arrayfun I tried to specify a sub-grid with
[u, v] = find(SF>0);
y_u = yo0(u);
x_v = xo0(v);
apply the conformal map to the sub-grid and separate real and imag
fxiy = 0.5*((x_v+1i.*y_u)+(1./(x_v+1i.*y_u)));
x_v = real(fxiy);
y_u = imag(fxiy);
and then exchange the transformed sub-grid in the original grid before generating the output image using interp2 (see complete Matlab code below as a low level conformal image mapping generalized from the Droste effect [login to view URL]).
But the output image looks the same as the input image. The task is to find a fast (vectorinzing) solution to transform a subgrid with fz.
[h_o,w_o,~] = size(SF);
[h_i,w_i,~] = size(img);
% GENERATE IN-GRID AND NORMALIZE [0 1]
[xi,yi] = meshgrid(linspace(0,w_i+1,w_i),linspace(0,h_i+1,h_i));
xi = xi/w_i;
yi = yi/h_i;
% GENERATE OUT-GRID AND NORMALIZE [-1 1]
[xo0,yo0] = meshgrid(1:w_o,1:h_o);
xo0 = (xo0/w_o)*2 - 1;
yo0 = (yo0/h_o)*2 - 1;
% FIND GRID POINTS WHERE CORRESPONDING COORDINATE IN SF FULFILLS CONDITION
[u, v] = find(SF>0);
y_u = yo0(u);
x_v = xo0(v);
% APPLY fz TO THOSE GRID POINTS
fxiy = 0.5*((x_v+1i.*y_u)+(1./(x_v+1i.*y_u)));
% SEPARATE real & imag
x_v = real(fxiy);
y_u = imag(fxiy);
% EXCHANGE MAPPED GRID POINTS
xo1 = xo0;
xo1(v) = x_v;
yo1 = yo0;
yo1(u) = y_u;
% NORMALIZE OUT-GRID [0 1]
xo1 = (xo1+1)/2;
yo1 = (yo1+1)/2;
% INTERPOLATE OUTPUT IMAGE
img_out = zeros(h_o,w_o,3);
for k = 1:3; img_out(:,:,k) = uint8(interp2(xi, yi, img(:,:,k), xo1, yo1, 'linear')); end;
Kitambulisho cha Mradi: #24714249
Kuhusu mradi
Imetuzwa kwa:
Hi, I am a mathematician with a specialty in image processing, your project is really interesting to me. I used to work with morphing and warping of an image using based physical process, also the conformal mesh mappin Zaidi
4 wafanyakazi huru wanazabuni wastani wa €23 kwa kazi hii
Hi! I have good experience in MATLAB programming. I can help you in improving your code and producing the desired output image. Kindly consider me for the project. Regards
Preamble: - This is a very small part of a non-commercial art project with a fixed budget of 30 EUR but no strict due date or deadline. A sufficient time intervall would be completion in 1 weeks. - Making higher price Zaidi