Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9171127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:07:15+00:00 2026-06-17T16:07:15+00:00

I am trying to understand some code in Mathematica, but am not familiar with

  • 0

I am trying to understand some code in Mathematica, but am not familiar with its syntax. I can’t seem to wrap my head around the logic here.

anamorph3[img_, angle_: 270 Degree, imgWidth_: 512] :=
Module[{data, f, matrix, dim, rOuter, rInner = 1.},
dim = ImageDimensions[img];
rOuter = rInner (1 + angle #2/#1 & @@ dim);
data = Table[
ListInterpolation[#[[All, All, i]], 
{{rOuter, rInner}, {-angle/2, angle/2}}], {i, 3}] &@ImageData[img];
f[i_, j_] := If[Abs[j] <= angle/2 && rInner <= i <= rOuter, 
Through[data[i, j]], {1., 1., 1.}];
Image@Table[f[Sqrt[i^2 + j^2], ArcTan[i, -j]], 
{i, -rOuter, rOuter, 2 rOuter/(imgWidth - 1)},
{j, -rOuter, rOuter, 2 rOuter/(imgWidth - 1)}]]

More details about this code can be found here

How to make ImageTransformation produce an anamorphic version of image.

It would be great if someone could write the pseudocode/ python code for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:07:15+00:00Added an answer on June 17, 2026 at 4:07 pm

    I suppose it would end up something like this:

    def anamorph3(img, angle = math.radians(270), imgWidth = 512):
        rInner = 1.
        dim = ImageDimensions(img)
        rOuter = rInner * (1 + angle * dim[2]/dim[1])
        data = list()
        for i in range(3):
            channelData = [[x[i] for x in v] for v in ImageData(img)]
            data.append(ListInterpolate(channelData, [[rOuter, rInner],[-angle/2,angle/2]]))
        def f(i, j):
            if abs(j) <= angle/2 && rInner <= i <= rOuter:
                l = list()
                for fun in data:
                    l.append(fun(i, j))
                return l
            else:
                return [1, 1, 1]
        newImageData = list()
        for i in range(-rOuter, rOuter, 2*rOuter/(imgWidth-1)):
            l = list()
            for j in range(-rOuter, rOuter, 2*rOuter/(imgWidth-1)):
                l.append(f(math.sqrt(i**2 + j**2), math.atan(i, -j)))
            newImageData.append(l)
        return Image(newImageData) 
    

    Here ImageDimensions return the dimensions for the image, ImageData returns a 3D matrix with the color data for each color channel for each pixel normalised to the range 0-1, and ListInterpolate creates a function that interpolates between a set of numbers within a specified x and y coordinate range. Image takes a 3D matrix and converts it to a RGB image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some code that i am trying to recompile and understand, but i
Sorry for the probably basic question, but I'm trying to understand some code and
I have some code I'm trying to understand while learning C#. I do not
I am trying to understand a third party Javascript code. But am not able
I'm trying to understand some C++ code which has the following class syntax: class
I'm testing some code(trying to make it faster but also trying to understand the
I am now trying to understand some code and I have found a pattern,
I've in inherited some code that I'm trying to understand and any searching I
I am trying to understand the Javascript event handling. I like some code to
I have some legacy C++ code that I am trying to understand a bit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.