Function Repository Resource:

RandomRorschach

Source Notebook

Generate random Rorschach tests

Contributed by: Anton Antonov

ResourceFunction["RandomRorschach"][]

makes a random Rorschach test image.

ResourceFunction["RandomRorschach"]["Graphics"]

makes a random Rorschach test graphics object.

ResourceFunction["RandomRorschach"]["HalfGraphics"]

makes the left half of a random Rorschach test graphics object.

ResourceFunction["RandomRorschach"]["Image"]

makes a random Rorschach test image.

ResourceFunction["RandomRorschach"]["HalfImage"]

gives the left half of a random Rorschach test image.

Details and Options

ResourceFunction["RandomRorschach"] takes a string argument that is expected to be one of "Graphics", "HalfGraphics", "Image" or "HalfImage".
By default, an image is returned (i.e. "Image" is the default value of the first argument).
With "Image", ResourceFunction["RandomRorschach"] makes a random filled scribble seed, reflects the seed over the right bounding box boundary and transforms the result with image effects.
With "Graphics", ResourceFunction["RandomRorschach"] does not apply image effects.
ResourceFunction["RandomRorschach"] takes all options of Rasterize and the resource function RandomScribble.
In addition, ResourceFunction["RandomRorschach"] takes the options "ImageEffects" and "CropSeed".
The option "ImageEffects" takes as a value a list of "second arguments" of ImageEffect or image manipulation functions that return images as results.
ResourceFunction["RandomRorschach"] has its own default values for the RandomScribble options "NumberOfStrokes", "OrderedStrokePoints" and "ConnectingFunction".
Here are the ResourceFunction["RandomRorschach"]-specific options and their default values:
"NumberOfStrokes"Defaultnumber of strokes in the scribble seed
"OrderedStrokePoints"Falsewhether to order the scribble stroke points or not
"ConnectingFunction"FilledCurve@*BezierCurveconnecting function for the scribble strokes
"ImageEffects"Defaultimage effects to be applied
"CropSeed"Truewhether to crop the seed or not

Examples

Basic Examples (2) 

Make a random Rorschach image:

In[1]:=
SeedRandom[32];
ResourceFunction["RandomRorschach"][]
Out[1]=

Make a random Rorschach graphics object:

In[2]:=
SeedRandom[87];
ResourceFunction["RandomRorschach"]["Graphics"]
Out[2]=

Scope (2) 

RandomRorschach takes a string argument that is expected to be one of "Graphics", "HalfGraphics", "Image" or "HalfImage". Here is a table with corresponding results:

In[3]:=
Grid[Transpose@
  Map[{#, BlockRandom[ResourceFunction["RandomRorschach"][#], RandomSeeding -> 33]} &, {"Graphics", "HalfGraphics", "Image", "HalfImage"}], Dividers -> All]
Out[3]=

The RandomRorschach results are controlled using options:

In[4]:=
SeedRandom[222];
ResourceFunction["RandomRorschach"][
 "ImageEffects" -> {{"Jitter", 12}, {"OilPainting", 9}}, "NumberOfStrokes" -> {6, 12, 9}, ColorFunction -> "Rainbow", ImageSize -> Small]
Out[4]=

Options (5) 

CropSeed (1) 

The option "CropSeed" specifies whether the seed is cropped (from its right side):

In[5]:=
Table[Labeled[
  BlockRandom[ResourceFunction["RandomRorschach"]["CropSeed" -> c], RandomSeeding -> 22], c], {c, {True, False, Automatic, Random}}]
Out[5]=

If the values Automatic or Random are given, then a logical value is randomly selected.

ConnectingFunction (1) 

The value of the option "ConnectingFunction" is passed to RandomScribble. Here are examples:

In[6]:=
Grid[Transpose@
  Map[{#, BlockRandom[
      ResourceFunction["RandomRorschach"]["ConnectingFunction" -> #, "ImageEffects" -> {"EdgeStylization"}], RandomSeeding -> 34]} &, {FilledCurve@*BezierCurve, Polygon, Line, Map[Disk[#, 0.12] &, #] &}], Dividers -> All]
Out[6]=

ImageEffects (1) 

The option "ImageEffects" can take a sequence of ImageEffect specs and other image manipulation functions:

In[7]:=
Grid[Transpose@
  Map[{#, BlockRandom[
      ResourceFunction["RandomRorschach"]["ImageEffects" -> #], RandomSeeding -> 45]} &, {Default, Automatic, {{"Jitter", 40}, {"OilPainting", 9}}, {ColorNegate, "Jitter"}}], Dividers -> All]
Out[7]=

If the value is Default, then the value is {{"OilPainting",5}}.

If the value is Automatic, then the code RandomChoice[{{"Jitter",10},"EdgeStylization",{"OilPainting",16}},2] is used.

NumberOfStrokes (1) 

The value of the option "NumberOfStrokes" can be Default, Automatic, a positive integer or a list of positive integers. It is passed to RandomScribble. Here are examples:

In[8]:=
Grid[Transpose@
  Map[{#, BlockRandom[
      ResourceFunction["RandomRorschach"]["NumberOfStrokes" -> #], RandomSeeding -> 89]} &, {Default, Automatic, 12, 200, {20, 30, 20}}], Dividers -> All]
Out[8]=

If the value is Default, then the code RandomInteger[{6,20}] is used.

If the value is Automatic, then the code RandomInteger[{5,20},3] is used.

OrderedStrokePoints (1) 

The option "OrderedStrokePoints" takes a logical value. The value is passed to RandomScribble. Here are examples:

In[9]:=
Grid[Transpose@
  Map[{#, BlockRandom[
      ResourceFunction["RandomRorschach"]["OrderedStrokePoints" -> #],
       RandomSeeding -> 77]} &, {False, True}], Dividers -> All]
Out[9]=

Properties and Relations (3) 

Using different color functions would, generally, produce different Rorschach interpretations. Here is a set of Rorschach test images:

In[10]:=
SeedRandom[33];
Multicolumn@
 Table[ResourceFunction["RandomRorschach"][
   "NumberOfStrokes" -> RandomInteger[{10, 20}], "ImageEffects" -> Automatic], 12]
Out[10]=

Here is another set of images with the same random seed and image effects as shown previously and a different color function:

In[11]:=
SeedRandom[33];
Multicolumn@
 Table[ResourceFunction["RandomRorschach"][
   "NumberOfStrokes" -> RandomInteger[{10, 20}], "ImageEffects" -> Automatic, ColorFunction -> "GrayTones"], 12]
Out[11]=

In some sense, the option "ImageEffects" is redundant because similar behavior can be achieved with standard Wolfram Language code. Nevertheless, using that option provides a quicker (and shorter) way to get desired results. Here is a Rorschach image creation specification:

In[12]:=
SeedRandom[332];
ResourceFunction["RandomRorschach"][
 "ImageEffects" -> {{"Jitter", 34}, "Sepia", RemoveBackground, ColorNegate, "OilPainting", Blur}]
Out[12]=

Here we generate the Rorschach "initial" image first and then modify it with the functions that correspond to the "ImageEffects" specification above:

In[13]:=
SeedRandom[332];
img = ResourceFunction["RandomRorschach"][];
Fold[#2[#1] &, img, {ImageEffect[#, {"Jitter", 34}] &, ImageEffect[#, "Sepia"] &, RemoveBackground, ColorNegate, ImageEffect[#, "OilPainting"] &, Blur}]
Out[13]=

The repository functions RandomScribble and RandomMandala are closely related to RandomRorschach:

In[14]:=
SeedRandom[228];
Grid[{{"RandomRorschach", "RandomScribble", "RandomMandala"}, {ResourceFunction["RandomRorschach"][], ResourceFunction["RandomScribble"][], ResourceFunction["RandomMandala"][]}}]
Out[14]=

Possible Issues (2) 

The values of the option "ImageEffects" might contain wrong second arguments for ImageEffect. In those cases, errors of ImageEffect are shown and the result is $Failed:

In[15]:=
ResourceFunction["RandomRorschach"]["ImageEffects" -> {"Jiter"}]
Out[15]=

$Failed is also returned if an element of the list is not a function that gives an image result:

In[16]:=
ResourceFunction["RandomRorschach"]["ImageEffects" -> {ColorNegation}]
Out[16]=

Neat Examples (4) 

A table of random Rorschach test images:

In[17]:=
SeedRandom[105];
Multicolumn@
 Table[ResourceFunction["RandomRorschach"][
   "NumberOfStrokes" -> {12, 16, 9}, "OrderedStrokePoints" -> RandomChoice[{False, True}], ColorFunction -> (Black &), "ImageEffects" -> Automatic], 12]
Out[17]=

Another table with the same random seed as shown previously but with a different color function and image effects:

In[18]:=
SeedRandom[105];
Multicolumn@
 Table[ResourceFunction["RandomRorschach"][
   "NumberOfStrokes" -> {12, 16, 9}, "OrderedStrokePoints" -> False, ColorFunction -> "Rainbow", "ImageEffects" -> {"Sepia", {"Jitter", 12}, RemoveBackground, Dilation[#, 2] &, ColorNegate}], 12]
Out[18]=

"Poodles", or "frogs", or an "electric bolts guy":

In[19]:=
SeedRandom[95];
ResourceFunction["RandomRorschach"][
 ColorFunction -> (GrayLevel[0.1] &), "ImageEffects" -> {{"OilPainting", 1}, "Jitter"}]
Out[19]=

The resource function XKCDConvert can be applied to the graphics results of RandomRorschach:

In[20]:=
SeedRandom[9141];
ResourceFunction["XKCDConvert"][
 ResourceFunction["RandomRorschach"]["Graphics"], "Distortion" -> 4]
Out[20]=

Publisher

Anton Antonov

Version History

  • 1.0.0 – 22 April 2022

Related Resources

License Information