Hoto na Dijital da Sadarwa a cikin Magunguna (DICOM) shine ma’auni don sadarwa da sarrafa bayanan hoton likita da bayanai masu alaƙa. Hakanan yana ƙunshe da hotuna monochrome da yawa tare da wadataccen tsarin metadata. Irin wannan bayanin na iya zama wani abu daga bayanan haƙuri, cibiyoyi, tsari, da ƙari. Bugu da ƙari, sanannen sa saboda suna iya samar da haɗin kai cikin sauƙi na na’urorin hoto na likita kamar su na’urori, sabar, wuraren aiki, firintocin, kayan aikin cibiyar sadarwa. Koyaya, don nuna hoton DICOM, muna buƙatar takamaiman aikace-aikacen kuma yana da wahala sosai lokacin da muke buƙatar nuna shi a cikin shafin yanar gizon. Don haka ɗayan mafi kyawun mafita shine canza DICOM zuwa tsarin JPG. Wani fa’idar fayilolin JPEG shine cewa ya ƙunshi hoto guda ɗaya (ko launi). Tunda hoton JPG ba shi da meta-data mai alaƙa, don haka yana rage girman hoton kuma abin fitarwa kuma yana matsawa / ƙarami cikin girman.
API ɗin Canjin Hotunan DICOM
Aspose.Imaging Cloud SDK for Java yana ba ku damar aiwatar da shahararrun hanyoyin sarrafa hotuna. Kuna iya shirya da canza hotunan raster, fayilolin Photoshop, Metafiles da sauran tsari kamar WebP. Hakazalika, yana da ikon sarrafa hotuna na DICOM kuma za mu yi amfani da shi don sauya tsarin DCM zuwa tsarin JPG. Yanzu don farawa da amfani da SDK, muna buƙatar ƙara bayaninsa a cikin aikin java ɗinmu ta haɗa da bin bayanai a cikin pom.xml (maven build type project).
<repositories>
<repository>
<id>aspose-cloud</id>
<name>artifact.aspose-cloud-releases</name>
<url>http://artifact.aspose.cloud/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-imaging-cloud</artifactId>
<version>22.4</version>
</dependency>
</dependencies>
Idan mun riga mun yi rajista akan Aspose Cloud Dashboard, da fatan za a sami takaddun shaidar abokin ciniki daga Cloud Dashboard. In ba haka ba, kuna buƙatar fara rajistar asusun kyauta yayin amfani da ingantaccen adireshin imel.
Tukar DCM ke JPG a Java
Wannan sashe yana ba da cikakkun bayanai kan yadda ake lodawa da canza DCM zuwa tsarin JPG ta amfani da snippet code na Java.
- Ƙirƙiri wani abu na ImagingApi ta amfani da keɓaɓɓen bayanan abokin ciniki
- Yanzu loda fayil ɗin DCM ta amfani da hanyar readAllBytes(…) kuma wuce zuwa byte[] array
- Ƙirƙiri misali na UploadFileRequest yayin samar da hujjar sunan hoton DICOM da loda shi zuwa ajiyar girgije ta amfani da hanyar uploadFile(…)
- Mataki na gaba shine ƙirƙirar wani abu na ConvertImageRequest wanda ke ɗaukar sunan DCM da JPG azaman mahawara
- Kira hanyar canzaImage(…) don canza tsarin DCM zuwa tsarin JPG kuma ana mayar da sakamakon azaman rafin amsawa
- A ƙarshe, ajiye sakamakon JPG zuwa faifan gida ta amfani da abu FileOutputStream
// Samu ClientID da ClientSecret daga https://dashboard.aspose.cloud/
String clientId = "7ef10407-c1b7-43bd-9603-5ea9c6db83cd";
String clientSecret = "ba7cc4dc0c0478d7b508dd8ffa029845";
// haifar da Hoto abu
ImagingApi imageApi = new ImagingApi(clientSecret, clientId);
// ɗora hoton DICOM daga faifan gida
File file1 = new File("skull_2.dcm");
byte[] imageStream = Files.readAllBytes(file1.toPath());
// ƙirƙiri abin buƙatar loda fayil
UploadFileRequest uploadRequest = new UploadFileRequest("input.dcm",imageStream,null);
// loda hoton DICOM zuwa ma'ajiyar gajimare
imageApi.uploadFile(uploadRequest);
// saka da fitarwa format na hoto
String format = "jpg";
// Ƙirƙiri abin buƙatar canza hoto
ConvertImageRequest convertImage = new ConvertImageRequest("input.dcm", format, null, null);
// canza DCM zuwa JPG kuma dawo da fitarwa a cikin rafin amsawa
byte[] resultantImage = imageApi.convertImage(convertImage);
// Ajiye sakamakon JPG zuwa faifan gida
FileOutputStream fos = new FileOutputStream("/Users/nayyer/Documents/" + "Resultant.jpg");
fos.write(resultantImage);
fos.close();
Hoton DICOM da aka yi amfani da shi a sama misali ana iya sauke shi daga skull2.dcm da fitarwa daga Resultant.jpg.
DCM zuwa JPG ta amfani da Umarnin CURL
Banda yaren shirye-shirye, REST APIs kuma ana iya samun dama ga umarnin cURL. Tun da Aspose.Imaging Cloud yana haɓaka kamar yadda REST gine, don haka a cikin wannan labarin, za mu tattauna cikakkun bayanai game da yadda ake canza DICOM Images zuwa JPG ta amfani da umarnin cURL. Matakan farko shine samar da alamar samun damar JWT (dangane da shaidar abokin ciniki) ta amfani da umarni mai zuwa.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Bayan tsarar JWT, da fatan za a aiwatar da wannan umarni don musanya DCM zuwa tsarin JPG.
curl -v -X GET "https://api.aspose.cloud/v3.0/imaging/input.dcm/convert?format=Resultant.jpg" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-o Resultant.jpg
Kammalawa
Mun tattauna dalla-dalla kan yadda za mu iya juyar da DICOM Hotunan zuwa tsarin JPG ta hanyar amfani da Aspose.Imaging Cloud SDK don Java. A lokaci guda, mun kuma bincika wani zaɓi don canza DCM zuwa JPG ta amfani da umarnin cURL. Bugu da ƙari, Takardun Samfura tushe ne mai ban mamaki na bayanai don koyo game da wasu abubuwan ban sha’awa waɗanda API ɗin ke bayarwa.
Lura cewa ana iya gwada fasalin API ɗin ta amfani da SwaggerUI a cikin mai binciken gidan yanar gizo kuma ana samun cikakkiyar lambar tushen Cloud SDK akan GitHub (a ƙarƙashin lasisin MIT), don haka kuna iya yin la’akari da zazzagewa kuma gyara shi gwargwadon dacewanku. A ƙarshe, idan kun gano kowace matsala yayin amfani da API, kuna iya yin la’akari da kusantar mu don ƙuduri mai sauri ta hanyar dandalin tallafi na kyauta 9.
Labarai masu alaka
Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: