我正在尝试使用imagemagick命令行工具将灰度图像转换为RGB .
它适用于PNG图像,使用:
convert image.png -define png:color-type=2 result.png
Run Code Online (Sandbox Code Playgroud)
(摘自"如何使用image magick将灰度png图像从命令行转换为RGB")
虽然检查identify -format %r result.png仍然会返回DirectClass灰色,我可以看到它使用,gdalinfo因为现在列出了3个频段/频道:
gdalinfo [成功转换PNG]:
Driver: PNG/Portable Network Graphics
Files: result.png
Size is 567, 479
Coordinate System is `'
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 479.0)
Upper Right ( 567.0, 0.0)
Lower Right ( 567.0, 479.0)
Center ( 283.5, 239.5)
Band 1 Block=567x1 Type=Byte, ColorInterp=Red
Band 2 Block=567x1 …Run Code Online (Sandbox Code Playgroud) 我想以可能的方式递归地DataFrame使用单个路径将给定文件夹中的所有csv文件读入Spark SQL .
我的文件夹结构看起来像这样,我希望包含一个路径的所有文件:
resources/first.csvresources/subfolder/second.csvresources/subfolder/third.csv这是我的代码:
def read: DataFrame =
sparkSession
.read
.option("header", "true")
.option("inferSchema", "true")
.option("charset", "UTF-8")
.csv(path)
Run Code Online (Sandbox Code Playgroud)
设置path于.../resource/*/*.csv省略1,而.../resource/*.csv忽略了2和3.
我知道csv()也会将多个字符串作为路径参数,但如果可能的话,我想避免这种情况.
注意:我知道我的问题类似于如何在单个加载中导入多个csv文件?,除了我想要包含所有包含的文件夹的文件,独立于他们在主文件夹中的位置.
apache-spark ×1
command-line ×1
csv ×1
dataframe ×1
grayscale ×1
imagemagick ×1
jpeg ×1
rgb ×1
scala ×1
wildcard ×1