Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fuzzycmeans.md #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions doc/source/fuzzycmeans.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,35 @@ M = R.centers
# memberships is a 20x3 matrix
memberships = R.weights
```

```@example julia Example of fcm on 2D images.
using TestImages, Clustering, ImageView

# Loads a gray scale image.
img = testimage("camera")
# Convert into a normal Array
img = Array{Float64,2}(img)

# Reshape that image into a vector.
Nx, Ny = size(img)
dat = reshape(img, 1, Nx*Ny)

#=
Feed in the image, # segments, show iteration info
and set max iterations
=#
result = fuzzy_cmeans(dat, 5, 2, display=:iter, maxiter=200)

#=
Take a look at one of the segments and reshape
the data back into its orginal form.

This image represents how much each pixel
belongs to a given segment. For example here we
are looking at segment 1.
=#
img_result = reshape(result.weights[:,1],Nx,Ny)

# View the newly segmented image.
imshow(img_result)