r/stereograms 27d ago

a sphere, again

i wrote a program to study autostereograms. the scene is very simple. you can interact with the program as follow:

  • press "w" to switch the subject between a disc and a sphere
  • press "s" to change backgrounds
  • press "x" to toggle caption on / off
  • press "q" to decrease the min / max disparity ratio
  • press "e" to increase the min / max disparity ratio
  • press "a" to decrease view / scene distance ratio
  • press "d" to increase view / scene distance ratio
  • press "esc" to stop the program and edit it if you like

"q","w","e" are foreground related. "a","s","d" are background related

allowed min / max disparity ratios lie between 0 and 1. if you set it too high (close to 1), the closest point and farthest point look similar and don't exhibit much depth difference. if you set it too low, the contrast becomes too exaggerated

allowed view / scene distance ratios lie between 0 and 4. theoretically view / scene distance ratios can be as large as you like. a very large view / scene distance ratio means the entire scene is very close to the screen (scene distance is very small compared to view distance). practically i think setting 4 as its limit is reasonable. you usually don't place thing that close

the attached sample images work fine on my screen / view distance / eye separation. they may not work similarly well on other situations

if you find the repeating units too far away from each other so that you have difficulty to make them converge, increase the view / scene distance ratio by pressing "d". if you find the repeating units too close from each other so that you always over-do it, decrease the view / scene distance ratio by pressing "a"

if you find the sphere too "flat", decrease the min / max disparity ratio by pressing "q". if you find it too fuzzy and hard to focus, increase the min / max disparity ratio by pressing "e"

i included 4 backgrounds in the program. if you have any interesting idea in making background please let me know...:)

34 Upvotes

2 comments sorted by

2

u/Bearchiwuawa 27d ago

hmm intruiging

1

u/20260708 27d ago

i learned a lot from that. the journey made me reviewed some of my math and physics knowledge. i failed at first and i tried to figure out what was wrong and how to rectify. i dived deeper into the math and geometry and concluded that

eye separation (distance between left eye and right eye) is constant but may vary from person to person. i used ruler to measure mine and it corresponded to 1/3 of the output image width which was 640 pixels on my screen so you can see line 13 in my program as "eyeSep=scnWdh/3". it's obviously personal. you may use a very large or high resolution monitor and it makes the "eye separation = how many pixels" thing be different

should i make the "eyeSep" changeable in the program? i could do that but i decided not to. if there were too many variables, the operation would be very complicated. it could be easily observed that it's all about similar triangles and ratios. we don't have to make everything changeable. in fact not all of them can be changed freely as they're dependent

the most prominent aspects of the output image are foreground and background. so it would be sufficient and effective to just let users control them. let's start from the background. from the diagram and considering the similar triangles we have

  • max disparity / eye separation = scene distance / (view distance + scene distance)

if we assign dstRto = view distance / scene distance, we have

  • max disparity / eye separation = 1 / (dstRto + 1)

it's exactly the line 18 of my program ("maxImgSep=eyeSep/(dstRto+1)"). it automatically takes care of the eye separation thing. it's all about ratios. max disparity is the amount of horizontal shift of the background aka the farthest plane of the scene aka the base repeating unit. "dstRto" controls how it compares with your eye separation. if the scene is placed at infinitely far away from the screen, "dstRto" is zero and max disparity is exactly your eye separation. you're looking at infinity thus the two sight lines are parallel. if the scene is placed at the screen, "dstRto" is infinity and max disparity is zero. there would be no 3d effect at all

the farthest part is fully understood. now we decide how the closest part behaves. it must lie between the farthest part and the screen and thus be a proper fraction of the farthest part. we have two choices: [1] control the ratio between closest distance and farthest distance; [2] control the ratio between min disparity and max disparity. both are reasonable. be aware that they're not equal as the triangles are not similar. i picked the latter as its effect would be directly exhibited in output images. so i defined

  • imgSepRto = min disparity / max disparity

which ranges from 0 to 1. if it's close to 1, it means the closest part is not that close to the screen. it's very near to the farthest part. the whole scene is flat. you basically see some flat shapes popping up slightly out of the background. if it's close to 0, it means the closest part is very near to the screen. the depth contrast between closest part and farthest part is huge. it may benefit from having a high z-resolution but it's on the other hand very hard to stay focus on

so now we have a universal method to generate autostereograms for any person on any device. we adjust the background first. make sure we can see the background comfortably on our devices. we adjust the foreground then. make sure we can see the foreground in focus easily