Learn R Programming

CTRing (version 0.1.0)

addRingFromImage: Add ring to pith to bark profile from CT scan image

Description

Add ring to pith to bark profile from CT scan image

Usage

addRingFromImage(n = 1, densProfile, im)

Value

Corrected density profile with new ring(s) added and blue bar in plot of added ring

Arguments

n

Number of rings to add

densProfile

Density profile

im

Density matrix

Examples

Run this code
library(oro.dicom)
file_path <- system.file("extdata", "disk.dcm", package = "CTRing")
dcm <-  readDICOM(file_path)
hdr_df <- dcm$hdr[[1]]
image_info <- getImageInfo(hdr = hdr_df)

im <- imageToMatrix(dcm$img)
im_8bit <- xBitTo8Bit(im, image_info$grayScale)
image_info <- getImageInfo(hdr = hdr_df)
im_dens <- grayToDensity(im_8bit)

pith_coord <- detect_pith(im_dens,
                          n_segments = 12,
                          pixel = TRUE,
                          toPlot = FALSE)

endPath <- c(472, 284)

densPath <- extractProfile(im_dens,
                           image_info,
                           pith_coord,
                           endPath,
                           k = 2, r = 5,
                           threshold = 0.002)

newPath2 <- addRingFromImage(n = 1, densPath, im_dens)

Run the code above in your browser using DataLab