Deep fields: pixel sorting Hubble images of deep space
by Jack Madden
Deep fields: pixel sorting Hubble images of deep space
by Jack Madden
A pixel sorter I made for my recent study of hubble deep field images. These images are typically used to showcase the fullness of the universe by showing thousands of galaxies in an area a few arcminutes across. By sorting the pixels by brightness we can really see how empty this space is. The final image uses all the same pixels as the original without edits, just a rearrangement. The interstitial spaces in these images represent lines of sight going nearly as far as the edge of the visible universe. Those black pixels deserve some attention too :)
Pixel sorter
Pixel sorter
A function to sort each row of pixels in an images. The row is split into 3 segments; sorted, unsorted, and reverse sorted. This allows the creation of various effects when the position and with of the middle section is changed.
deepfields[source_,fraction_,width_,sort_,rotate_,size_]:=Module[{newpic={},left,middle,right,picsort,picdat=source},If[rotate0,,picdat=Transpose[picdat]];Do[left=SortBy[picdat[[i,1;;Floor[Length[picdat[[i]]]*fraction]]],sort];middle=picdat[[i,Floor[Length[picdat[[i]]]*fraction+1];;Floor[Length[picdat[[i]]]*(fraction+width)]]];right=Reverse[SortBy[picdat[[i,Floor[Length[picdat[[i]]]*(fraction+width)+1];;All]],sort]];AppendTo[newpic,Join[left,middle,right]];,{i,1,Length[picdat]}];If[rotate0,,newpic=Transpose[newpic]];Image[newpic,ImageSizesize]]
Image import and prep
Image import and prep
Some of the images I want to work with are really large and would not be easy to work with directly in the manipulate. If we preload the image and create a smaller version then manipulate is happy. Images are from Hubblesite https://hubblesite.org/resource-gallery
In[]:=
SetDirectory[NotebookDirectory[]];
In[]:=
filename="HUDF_2880.png";pic=RemoveAlphaChannel[Import[filename],White];pic=
;(*fortheonlinenotebook*)datFull=ImageData[ImageResize[pic,Full]];datLR=ImageData[ImageResize[pic,Large]];
Deep Fields Manipulate
Deep Fields Manipulate
In[]:=
Manipulate[deepfields[datLR,fraction,width,sort,rotate,Large],Button["Save",Export[ToString[filename]<>"_"<>ToString[fraction]<>"."<>ToString[width]<>"."<>ToString[rotate]<>"."<>ToString[sort]<>".png",deepfields[datFull,fraction,width,sort,rotate,Full]],Method"Queued"],{{fraction,.68,Dynamic["Fraction:"<>ToString[PaddedForm[fraction,{3,2}]]]},0,1-width,0.05},{{width,0.11,Dynamic["Width:"<>ToString[PaddedForm[width,{3,2}]]]},0,1-fraction,0.01},{{rotate,0,"Rotate:"},{0,1}},{{sort,Total,"Sort Type:"},{Total,Mean,Max,Min,First,Last}},DeployedTrue,SaveDefinitionsTrue]
Out[]=
More Examples
More Examples
M79
Hubble legacy survey

