Skip to content

Commit b5a8d99

Browse files
authored
Rename ImageType to ImageDataViewType (#3055)
1 parent 42db9a2 commit b5a8d99

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

src/Microsoft.ML.ImageAnalytics/ExtensionsCatalog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ internal static ImageResizingEstimator ResizeImages(this TransformsCatalog catal
178178
=> new ImageResizingEstimator(CatalogUtils.GetEnvironment(catalog), columnOptions);
179179

180180
/// <summary>
181-
/// Converts vectors of pixels into <see cref="ImageType"/> representation.
181+
/// Converts vectors of pixels into <see cref="ImageDataViewType"/> representation.
182182
/// </summary>
183183
/// <param name="catalog">The transform's catalog.</param>
184184
/// <param name="columnOptions">The <see cref="VectorToImageConvertingEstimator.ColumnOptions"/> describing how the transform handles each vector to image conversion column pair.</param>
@@ -187,7 +187,7 @@ internal static VectorToImageConvertingEstimator ConvertToImage(this TransformsC
187187
=> new VectorToImageConvertingEstimator(CatalogUtils.GetEnvironment(catalog), columnOptions);
188188

189189
/// <summary>
190-
/// Converts vectors of pixels into <see cref="ImageType"/> representation.
190+
/// Converts vectors of pixels into <see cref="ImageDataViewType"/> representation.
191191
/// </summary>
192192
/// <param name="catalog">The transforms' catalog.</param>
193193
/// <param name="imageHeight">The height of the output images.</param>

src/Microsoft.ML.ImageAnalytics/ImageGrayscale.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private protected override void SaveModel(ModelSaveContext ctx)
164164

165165
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
166166
{
167-
if (!(inputSchema[srcCol].Type is ImageType))
167+
if (!(inputSchema[srcCol].Type is ImageDataViewType))
168168
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", ColumnPairs[col].inputColumnName, "image", inputSchema[srcCol].Type.ToString());
169169
}
170170

@@ -264,8 +264,8 @@ public override SchemaShape GetOutputSchema(SchemaShape inputSchema)
264264
{
265265
if (!inputSchema.TryFindColumn(colInfo.inputColumnName, out var col))
266266
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", colInfo.inputColumnName);
267-
if (!(col.ItemType is ImageType) || col.Kind != SchemaShape.Column.VectorKind.Scalar)
268-
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", colInfo.inputColumnName, new ImageType().ToString(), col.GetTypeString());
267+
if (!(col.ItemType is ImageDataViewType) || col.Kind != SchemaShape.Column.VectorKind.Scalar)
268+
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", colInfo.inputColumnName, new ImageDataViewType().ToString(), col.GetTypeString());
269269

270270
result[colInfo.outputColumnName] = new SchemaShape.Column(colInfo.outputColumnName, col.Kind, col.ItemType, col.IsKey, col.Annotations);
271271
}

src/Microsoft.ML.ImageAnalytics/ImageLoader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ private static VersionInfo GetVersionInfo()
168168
private sealed class Mapper : OneToOneMapperBase
169169
{
170170
private readonly ImageLoadingTransformer _parent;
171-
private readonly ImageType _imageType;
171+
private readonly ImageDataViewType _imageType;
172172

173173
public Mapper(ImageLoadingTransformer parent, DataViewSchema inputSchema)
174174
: base(parent.Host.Register(nameof(Mapper)), parent, inputSchema)
175175
{
176-
_imageType = new ImageType();
176+
_imageType = new ImageDataViewType();
177177
_parent = parent;
178178
}
179179

@@ -241,7 +241,7 @@ protected override DataViewSchema.DetachedColumn[] GetOutputColumnsCore()
241241
/// </remarks>
242242
public sealed class ImageLoadingEstimator : TrivialEstimator<ImageLoadingTransformer>
243243
{
244-
private readonly ImageType _imageType;
244+
private readonly ImageDataViewType _imageType;
245245

246246
/// <summary>
247247
/// Load images in memory.
@@ -257,7 +257,7 @@ internal ImageLoadingEstimator(IHostEnvironment env, string imageFolder, params
257257
internal ImageLoadingEstimator(IHostEnvironment env, ImageLoadingTransformer transformer)
258258
: base(Contracts.CheckRef(env, nameof(env)).Register(nameof(ImageLoadingEstimator)), transformer)
259259
{
260-
_imageType = new ImageType();
260+
_imageType = new ImageDataViewType();
261261
}
262262

263263
/// <summary>

src/Microsoft.ML.ImageAnalytics/ImagePixelExtractor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace Microsoft.ML.Transforms.Image
3333
/// <see cref="ITransformer"/> produced by fitting the <see cref="IDataView"/> to an <see cref="ImagePixelExtractingEstimator" /> .
3434
/// </summary>
3535
/// <remarks>
36-
/// During the transformation, the columns of <see cref="ImageType"/> are converted them into a vector representing the image pixels
36+
/// During the transformation, the columns of <see cref="ImageDataViewType"/> are converted them into a vector representing the image pixels
3737
/// than can be further used as features by the algorithms added to the pipeline.
3838
/// <seealso cref="ImageEstimatorsCatalog.ExtractPixels(TransformsCatalog, ImagePixelExtractingEstimator.ColumnOptions[])" />
3939
/// <seealso cref="ImageEstimatorsCatalog.ExtractPixels(TransformsCatalog, string, string, ImagePixelExtractingEstimator.ColorBits, ImagePixelExtractingEstimator.ColorsOrder, bool, float, float, bool)" />
@@ -275,7 +275,7 @@ private protected override void SaveModel(ModelSaveContext ctx)
275275
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
276276
{
277277
var inputColName = _columns[col].InputColumnName;
278-
var imageType = inputSchema[srcCol].Type as ImageType;
278+
var imageType = inputSchema[srcCol].Type as ImageDataViewType;
279279
if (imageType == null)
280280
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", inputColName, "image", inputSchema[srcCol].Type.ToString());
281281
if (imageType.Height <= 0 || imageType.Width <= 0)
@@ -458,7 +458,7 @@ private VectorType[] ConstructTypes()
458458
var column = _parent._columns[i];
459459
Contracts.Assert(column.Planes > 0);
460460

461-
var type = InputSchema[ColMapNewToOld[i]].Type as ImageType;
461+
var type = InputSchema[ColMapNewToOld[i]].Type as ImageDataViewType;
462462
Contracts.Assert(type != null);
463463

464464
int height = type.Height;
@@ -800,8 +800,8 @@ public override SchemaShape GetOutputSchema(SchemaShape inputSchema)
800800
{
801801
if (!inputSchema.TryFindColumn(colInfo.InputColumnName, out var col))
802802
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", colInfo.InputColumnName);
803-
if (!(col.ItemType is ImageType) || col.Kind != SchemaShape.Column.VectorKind.Scalar)
804-
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", colInfo.InputColumnName, new ImageType().ToString(), col.GetTypeString());
803+
if (!(col.ItemType is ImageDataViewType) || col.Kind != SchemaShape.Column.VectorKind.Scalar)
804+
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", colInfo.InputColumnName, new ImageDataViewType().ToString(), col.GetTypeString());
805805

806806
var itemType = colInfo.OutputAsFloatArray ? NumberDataViewType.Single : NumberDataViewType.Byte;
807807
result[colInfo.Name] = new SchemaShape.Column(colInfo.Name, SchemaShape.Column.VectorKind.Vector, itemType, false);

src/Microsoft.ML.ImageAnalytics/ImageResizer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private protected override void SaveModel(ModelSaveContext ctx)
260260

261261
private protected override void CheckInputColumn(DataViewSchema inputSchema, int col, int srcCol)
262262
{
263-
if (!(inputSchema[srcCol].Type is ImageType))
263+
if (!(inputSchema[srcCol].Type is ImageDataViewType))
264264
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", _columns[col].InputColumnName, "image", inputSchema[srcCol].Type.ToString());
265265
}
266266

@@ -512,7 +512,7 @@ public ColumnOptions(string name,
512512
ImageHeight = imageHeight;
513513
Resizing = resizing;
514514
Anchor = anchor;
515-
Type = new ImageType(ImageHeight, ImageWidth);
515+
Type = new ImageDataViewType(ImageHeight, ImageWidth);
516516
}
517517
}
518518

@@ -564,8 +564,8 @@ public override SchemaShape GetOutputSchema(SchemaShape inputSchema)
564564
{
565565
if (!inputSchema.TryFindColumn(colInfo.InputColumnName, out var col))
566566
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", colInfo.InputColumnName);
567-
if (!(col.ItemType is ImageType) || col.Kind != SchemaShape.Column.VectorKind.Scalar)
568-
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", colInfo.InputColumnName, new ImageType().ToString(), col.GetTypeString());
567+
if (!(col.ItemType is ImageDataViewType) || col.Kind != SchemaShape.Column.VectorKind.Scalar)
568+
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", colInfo.InputColumnName, new ImageDataViewType().ToString(), col.GetTypeString());
569569

570570
result[colInfo.Name] = new SchemaShape.Column(colInfo.Name, SchemaShape.Column.VectorKind.Scalar, colInfo.Type, false);
571571
}

src/Microsoft.ML.ImageAnalytics/ImageType.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
namespace Microsoft.ML.Transforms.Image
1111
{
12-
public sealed class ImageType : StructuredDataViewType
12+
public sealed class ImageDataViewType : StructuredDataViewType
1313
{
1414
public readonly int Height;
1515
public readonly int Width;
16-
public ImageType(int height, int width)
16+
public ImageDataViewType(int height, int width)
1717
: base(typeof(Bitmap))
1818
{
1919
Contracts.CheckParam(height > 0, nameof(height), "Must be positive.");
@@ -23,15 +23,15 @@ public ImageType(int height, int width)
2323
Width = width;
2424
}
2525

26-
public ImageType() : base(typeof(Bitmap))
26+
public ImageDataViewType() : base(typeof(Bitmap))
2727
{
2828
}
2929

3030
public override bool Equals(DataViewType other)
3131
{
3232
if (other == this)
3333
return true;
34-
if (!(other is ImageType tmp))
34+
if (!(other is ImageDataViewType tmp))
3535
return false;
3636
if (Height != tmp.Height)
3737
return false;

src/Microsoft.ML.ImageAnalytics/VectorToImageTransform.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ private protected override void CheckInputColumn(DataViewSchema inputSchema, int
315315
private sealed class Mapper : OneToOneMapperBase
316316
{
317317
private readonly VectorToImageConvertingTransformer _parent;
318-
private readonly ImageType[] _types;
318+
private readonly ImageDataViewType[] _types;
319319

320320
public Mapper(VectorToImageConvertingTransformer parent, DataViewSchema inputSchema)
321321
: base(parent.Host.Register(nameof(Mapper)), parent, inputSchema)
@@ -419,15 +419,15 @@ private ValueGetter<Bitmap> GetterFromType<TValue>(PrimitiveDataViewType srcType
419419
};
420420
}
421421

422-
private static ImageType[] ConstructTypes(VectorToImageConvertingEstimator.ColumnOptions[] columns)
422+
private static ImageDataViewType[] ConstructTypes(VectorToImageConvertingEstimator.ColumnOptions[] columns)
423423
{
424-
return columns.Select(c => new ImageType(c.ImageHeight, c.ImageWidth)).ToArray();
424+
return columns.Select(c => new ImageDataViewType(c.ImageHeight, c.ImageWidth)).ToArray();
425425
}
426426
}
427427
}
428428

429429
/// <summary>
430-
/// <see cref="IEstimator{TTransformer}"/> that converts vectors containing pixel representations of images in to<see cref="ImageType"/> representation.
430+
/// <see cref="IEstimator{TTransformer}"/> that converts vectors containing pixel representations of images in to<see cref="ImageDataViewType"/> representation.
431431
/// </summary>
432432
/// <remarks>
433433
/// Calling <see cref="IEstimator{TTransformer}.Fit(IDataView)"/> in this estimator, produces an <see cref="VectorToImageConvertingTransformer"/>.
@@ -736,7 +736,7 @@ public override SchemaShape GetOutputSchema(SchemaShape inputSchema)
736736
if (col.Kind != SchemaShape.Column.VectorKind.Vector || (col.ItemType != NumberDataViewType.Single && col.ItemType != NumberDataViewType.Double && col.ItemType != NumberDataViewType.Byte))
737737
throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", colInfo.InputColumnName, "known-size vector of type float, double or byte", col.GetTypeString());
738738

739-
var itemType = new ImageType(colInfo.ImageHeight, colInfo.ImageWidth);
739+
var itemType = new ImageDataViewType(colInfo.ImageHeight, colInfo.ImageWidth);
740740
result[colInfo.Name] = new SchemaShape.Column(colInfo.Name, SchemaShape.Column.VectorKind.Scalar, itemType, false);
741741
}
742742

src/Microsoft.ML.StaticPipe/ImageStaticPipe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.ML.StaticPipe
1212
{
1313
/// <summary>
1414
/// A type used in the generic argument to <see cref="Scalar{T}"/>. We must simultaneously distinguish
15-
/// between a <see cref="ImageType"/> of fixed (with <see cref="Bitmap"/>) and unfixed (with this type),
15+
/// between a <see cref="ImageDataViewType"/> of fixed (with <see cref="Bitmap"/>) and unfixed (with this type),
1616
/// in the static pipelines.
1717
/// </summary>
1818
public class UnknownSizeBitmap { private UnknownSizeBitmap() { } }

test/Microsoft.ML.Core.Tests/UnitTests/ColumnTypes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void TestEqualAndGetHashCode()
9494
for (int height = 1; height < 5; height++)
9595
for (int width = 1; width < 5; width++)
9696
{
97-
var tmp4 = new ImageType(height, width);
97+
var tmp4 = new ImageDataViewType(height, width);
9898
if (dict.ContainsKey(tmp4))
9999
Assert.True(false, dict[tmp4] + " and " + tmp4.ToString() + " are duplicates.");
100100
dict[tmp4] = tmp4.ToString();

0 commit comments

Comments
 (0)