Matlab: Selecting a meshgrid subset and transform it with a conformal map

Completed Posted 3 years ago Paid on delivery
Completed Paid on delivery

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;

Matlab and Mathematica Algorithm Mathematics Image Processing

Project ID: #24714249

About the project

4 proposals Remote project Active 3 years ago

Awarded to:

cargamento2000

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 More

€29 EUR in 7 days
(5 Reviews)
3.2

4 freelancers are bidding on average €23 for this job

lancing4you

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

€24 EUR in 3 days
(11 Reviews)
3.3
DuongTom

hello employer nice to meet you I think you need an expert matlab. well I am here to help you my fields are electronic warfare, communication technologies, radar systems and Simulink and digital signal and image proces More

€19 EUR in 7 days
(4 Reviews)
3.8
akshayparanjape2

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 More

€20 EUR in 2 days
(0 Reviews)
0.0