Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Locate shapes and replace with dots. (Photoshop, After Effects, Illustrator or other software)

Community Beginner ,
Nov 20, 2021 Nov 20, 2021

Copy link to clipboard

Copied

Hey All!

From time to time it comes up that I have an image of random shapes (in this case stars) that are not completely round, but more randomly shaped, which makes them in this case look more like snowflakes.

 

I'm trying to find a way to locate all the stars and place a dot on top of them with roughly the same size of the original star. Or find another way to make the existing stars completely round. I used edge detection to separate the stars from the background, so that they are 100% white to make it easier.

 

Has someone any ideas on how to do that with Photoshop, After Effects, Illustrator or any other software that may have a feature that can be used, or partially used to solve the problem?

 

If someone does not have a full solution, but just some thoughts, please still post them. Maybe it already helps. 🙂

 

I've attached an example image of what I'm talking about.

example3b.png

TOPICS
Actions and scripting

Views

147

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Beginner , Nov 22, 2021 Nov 22, 2021
That's a very good idea with the symbol replace script. Thanks a lot! While searching for that I found something similar that does exactly what I need here: http://illustrator.hilfdirselbst.ch/dokuwiki/en/skripte/javascript/zamena_size I've also tried the "Find and Replace Graphics" script here: http://kelsocartography.com/scripts/#nvkAlso similar, but it's not quite what I need, since it strechtes in X and Y direction which results in ellipses rather than circles. But I've included it here in ...

Likes

Translate

Translate
Community Beginner , Nov 22, 2021 Nov 22, 2021
Oh true it is suprisingly short!I tried many different keywords. I think something like "illustrator replace shape" got me to this result.It got me to this thread where both scripts were linked to by other users:https://community.adobe.com/t5/illustrator-discussions/replace-multiple-objects-in-illustrator/m-p/8572551 Here is everything I did in order. Also for me as a reminder since I don't use Illustrator much:Preparation:1. vectorize the image with Properties > Image Trace2. play with settings...

Likes

Translate

Translate
Adobe Community Professional ,
Nov 20, 2021 Nov 20, 2021

Copy link to clipboard

Copied

I know no currently available method to truly and effectively achieve this. 

Overlapping »clusters« (see screenshot) make it difficult to determine individual objects/centers. 

Screenshot 2021-11-20 at 12.17.59.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 20, 2021 Nov 20, 2021

Copy link to clipboard

Copied

Yes true the touching shapes are problematic, but if it would count them as one dot, that would already be better than nothing. Then I could manually adjust them later on if some happen to be to big.

 

Thanks for the input regardless!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 20, 2021 Nov 20, 2021

Copy link to clipboard

Copied

In that case I think there might be options, though not necessarily speedy ones. 

Illustrator or After Effects might offer better ones, but in Photoshop one could use a Script to create a Work Path based on the image loaded as a Selection, then evaluate all the subPathItems (approximate a center and a »width« if not an actual »radius«) and create a Path with circular supPathItems. 

 

Maybe someone else has a better idea? 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 21, 2021 Nov 21, 2021

Copy link to clipboard

Copied

Maybe something like that would work. Unfortunately I don't have enough knowledge of scripting to do that.

 

But thanks for the idea!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 21, 2021 Nov 21, 2021

Copy link to clipboard

Copied

If we use paths to find closed contours, then I'm afraid that a significant part of the stars 1-2 pixels in size will be lost.

2021-11-21_23-38-42.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 21, 2021 Nov 21, 2021

Copy link to clipboard

Copied

They won't if you cut out those you made paths from and then use Color Range on the rest to expand their selection size a little. Finally you change them to paths, so you save each pixel! 🙂

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2021 Nov 22, 2021

Copy link to clipboard

Copied

I actually first tried the "Auto-trace" feature in After Effects today, which worked perfectly in the preview and managed to get all the stars, but when clicking OK it filled 64gb of ram and then crashed. Then I thought, well Illustrator is basically made for this so why do I use After Effects and yes, Illustrator got them all and I now have a vector version of it. It found close to 10000 individual paths, so that's probably the reason After Effects crashed.

Illustrator even has a way to replace the shapes with ellipses under "Effects > Convert to Shape", but those are unfortunately not really round and sometimes way bigger than the original shape (outlined in blue).

Screenshot 2021-11-22 09.03.44.png

so close..


Pixxxelschubsers comment down below then guided me into the right direction to find exactly what I need.
Thanks a lot for the discussions here in this thread!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 21, 2021 Nov 21, 2021

Copy link to clipboard

Copied

Try to use the "Illustrator way" with a Replace with symbol script.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2021 Nov 22, 2021

Copy link to clipboard

Copied

That's a very good idea with the symbol replace script. Thanks a lot! While searching for that I found something similar that does exactly what I need here: http://illustrator.hilfdirselbst.ch/dokuwiki/en/skripte/javascript/zamena_size

 

Screenshot 2021-11-22 10.30.27.png

 

I've also tried the "Find and Replace Graphics" script here: http://kelsocartography.com/scripts/#nvk

Also similar, but it's not quite what I need, since it strechtes in X and Y direction which results in ellipses rather than circles. But I've included it here in case someone stumbles across this thread and it works better for their needs.

 

Thanks a lot everyone in this thread!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 22, 2021 Nov 22, 2021

Copy link to clipboard

Copied

I wonder what keywords you used on 'google' when trying to find these scripts? btw the script you used is very short, is it everything what has to be done in Illustrator, run it on an image?

 

mySelection = activeDocument.selection

if (mySelection.length > 0) {
	if (mySelection instanceof Array) {
		goal = mySelection[0]
		centerPoint = goal.position[0] + (goal.width / 2)
		centerPointVert = goal.position[1] - (goal.height / 2)

		for(i = 1; i < mySelection.length; i++) {
			currItem = mySelection[i]
			centerPoint = currItem.position[0] + (currItem.width / 2)
			centerPointVert = currItem.position[1] - (currItem.height / 2)
			ratio = 100 / (goal.width / currItem.width)
			ratioV = 100 / (goal.height / currItem.height)
			newItem = goal.duplicate()
			newItem.position = Array((centerPoint - (goal.width / 2)), (centerPointVert + (goal.height / 2)))

			 if (ratio < ratioV) newItem.resize(ratio, ratio, true, true, true, true, ratio)
			 else newItem.resize(ratioV, ratioV, true, true, true, true, ratioV)

			 newItem.artworkKnockout = currItem.artworkKnockout
			 newItem.clipping = currItem.clipping
			 newItem.isIsolated = currItem.isIsolated
			 newItem.evenodd = currItem.evenodd
			 
			 if (currItem.polarity) newItem.polarity = currItem.polarity

			newItem.moveBefore(currItem)
			currItem.remove()
		}
	}
}

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2021 Nov 22, 2021

Copy link to clipboard

Copied

LATEST

Oh true it is suprisingly short!

I tried many different keywords. I think something like "illustrator replace shape" got me to this result.

It got me to this thread where both scripts were linked to by other users:

https://community.adobe.com/t5/illustrator-discussions/replace-multiple-objects-in-illustrator/m-p/8...

 

Here is everything I did in order. Also for me as a reminder since I don't use Illustrator much:

Preparation:

1. vectorize the image with Properties > Image Trace

2. play with settings to get it more accurate

Using the script:

1. create a circle (every selected shape will be replace with this circle)

2. select all objects that should be replaced

3. then select the circle (the replacement) last

4. go to file > scripts > zamena_size

(available here: http://illustrator.hilfdirselbst.ch/dokuwiki/en/skripte/javascript/zamena_size)
5. done! In my case it took a few minutes due to the thousands of stars.

 

The other script works the same way.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines